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 001/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 002/151] =?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 003/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 004/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 005/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 006/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 007/151] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=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 -> { From 8c10231f0dd96175da799b1fe5efbfe25e81e563 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 8 May 2024 13:40:23 +0800 Subject: [PATCH 008/151] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E5=A1=AB=E8=A1=A5=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 2e170cd..bc33c70 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -60,7 +60,7 @@ public class GenerateServiceImpl extends BaseServiceImpl Date: Wed, 8 May 2024 14:44:57 +0800 Subject: [PATCH 009/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E9=99=90?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98=E5=AE=8C=E6=88=90=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 54 +++++++++++++--------- .../bigmodel/schedule/InteractiveSchedule.java | 51 +++++++++++--------- .../websocket/handler/InteractiveHandler.java | 3 +- 3 files changed, 61 insertions(+), 47 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 d9e2efb..d3af689 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 @@ -4,20 +4,17 @@ import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -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.CollectionUtil; import org.springblade.core.tool.utils.Func; @@ -29,15 +26,10 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; +import java.util.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; +import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; /** * @Author: huangxing * @Date: 2024/04/26 14:51 @@ -47,31 +39,39 @@ import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; @RequiredArgsConstructor public class InteractiveServiceImpl implements IInteractiveService { + private final BladeLogger logger; + private final IJumpPageService jumpPageService; + private final IFunctionService functionService; + private final BigModelInvokeUrl bigModelInvokeUrl; - private final BladeLogger logger; + private final IDeptClient deptClient; + private final IUserClient userClient; + + private final RedisTemplate redisTemplate; + @Value("${fdp.host}") private String fdpHost; + private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); - switch (typeEnum) { - // 页面跳转 - case JUMP: - String extra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); - Assert.isTrue(StringUtil.isNotBlank(extra) && Func.isNotEmpty(extra), () -> { - throw new ServiceException("解析" + function.getName() + "函数失败!"); - }); - return R.data(extra); - default: - throw new ServiceException("函数解析失败!"); + // 页面跳转 + if (Objects.requireNonNull(typeEnum) == TypeEnum.JUMP) { + String extra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); + Assert.isTrue(StringUtil.isNotBlank(extra) && Func.isNotEmpty(extra), () -> { + throw new ServiceException("解析" + function.getName() + "函数失败!"); + }); + return R.data(extra); } + throw new ServiceException("函数解析失败!"); } @Override @@ -79,7 +79,7 @@ public class InteractiveServiceImpl implements IInteractiveService { //TODO 保存问题 Map params = new HashMap<>(); params.put("id",sessionId); - params.put("userid",userId.toString()); + params.put("userid", userId); params.put("query",question); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); @@ -87,6 +87,14 @@ public class InteractiveServiceImpl implements IInteractiveService { log.error("远程调用大模型【发起问答】接口失败!"); return R.fail("远程调用大模型【发起问答】接口失败!"); } + // 添加redis问题会话 + List asks = (List) redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + if(CollectionUtil.isEmpty(asks)){ + asks = Collections.singletonList(sessionId); + }else{ + asks.add(sessionId); + } + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,asks); return R.success("消息发送成功"); } 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 56af36e..13b6344 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 @@ -3,31 +3,23 @@ package com.hnac.hzims.bigmodel.schedule; import com.alibaba.fastjson.JSON; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.websocket.server.InteractiveWsServer; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.Func; -import org.springblade.system.cache.ParamCache; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; -import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; -import java.io.IOException; -import java.util.Enumeration; import java.util.List; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; -import java.util.stream.Collectors; -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.GET_INTERACTIVE_RESULT; /** * @Author: huangxing @@ -37,11 +29,16 @@ import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; @AllArgsConstructor public class InteractiveSchedule { - private final RedisTemplate redisTemplate; private final InteractiveWsService wsService; + private final IInteractiveService interactiveService; + private final ThreadPoolExecutor getAnswerPoolExecutor; + private final RedisTemplate redisTemplate; + + private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + // @XxlJob(GET_INTERACTIVE_RESULT) // public ReturnT execute(String params) { // String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); @@ -68,17 +65,27 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT execute(String params) { List sessionIds = InteractiveSessionManager.getSessionIds(); - 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 -> { - CompletableFuture.runAsync(() -> { - XxlJobLogger.log("开始获取"+answerVO.getSessionId()+"答案!"); - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); - }, getAnswerPoolExecutor); - }); + XxlJobLogger.log("开始获取到sessionId:"+ String.join(",", sessionIds)); + List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); + XxlJobLogger.log("获取到答案:"+JSON.toJSONString(answerList)); + answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { + XxlJobLogger.log("开始获取"+answerVO.getSessionId()+"答案!"); + List asks = (List) redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + // 问题回答完成,去除redis问题标记 + if(answerVO.getStatus() == 0){ + if(CollectionUtil.isNotEmpty(asks) && asks.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(session,message); + } + asks.remove(answerVO.getSessionId()); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,asks); + return; + } + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",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/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index a2dc3c6..6c030fb 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 @@ -56,8 +56,7 @@ public class InteractiveHandler extends TextWebSocketHandler { } catch (IOException e) { throw new RuntimeException(e); } - } - else { + }else { // 发送问题 String context = messageJSON.getString("context"); String userId = messageJSON.getString("userId"); From d6f7260baf225a0d497ccfb3f7b4967a36dc24d6 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 8 May 2024 15:31:47 +0800 Subject: [PATCH 010/151] =?UTF-8?q?fix:=E9=89=B4=E6=9D=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 21 ++++++++++++++------- pom.xml | 6 ++++-- 2 files changed, 18 insertions(+), 9 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 d9e2efb..f0bf166 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 @@ -22,6 +22,7 @@ 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.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; @@ -36,6 +37,7 @@ import javax.servlet.http.HttpSession; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; /** @@ -76,11 +78,12 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public R ask(String question,String sessionId,String userId) { - //TODO 保存问题 - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("id",sessionId); params.put("userid",userId.toString()); params.put("query",question); + params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); if(response.getStatus() != HttpServletResponse.SC_OK) { @@ -107,11 +110,8 @@ public class InteractiveServiceImpl implements IInteractiveService { public Boolean authentication(String stationId, String userId, String funcCode) { // 站点鉴权 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(); + List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) + .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); Assert.isTrue(stations.contains(stationId),() -> { throw new ServiceException("人员站点鉴权失败!"); }); @@ -130,4 +130,11 @@ public class InteractiveServiceImpl implements IInteractiveService { return true; } + private List getStationPermissionsById(String userId) { + R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + return deptSattionR.getData(); + } } diff --git a/pom.xml b/pom.xml index 182b612..3339d22 100644 --- a/pom.xml +++ b/pom.xml @@ -49,12 +49,14 @@ org.springblade blade-system-api - ${bladex.project.version} + + 5.1.1.RELEASE.fix.4 org.springblade blade-user-api - ${bladex.project.version} + + 5.1.1.RELEASE.fix.4 org.springblade From caf4c76a52c2f3fe19104e6c2faa41d879a604a5 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 8 May 2024 15:45:15 +0800 Subject: [PATCH 011/151] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E9=97=AE?= =?UTF-8?q?=E7=AD=94=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 7498bd0..d8d4291 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 @@ -96,6 +96,7 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); + logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body()); if(response.getStatus() != HttpServletResponse.SC_OK) { log.error("远程调用大模型【发起问答】接口失败!"); return R.fail("远程调用大模型【发起问答】接口失败!"); From 534eb51ff1534a82bfd70167d74621139159b080 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 8 May 2024 15:51:54 +0800 Subject: [PATCH 012/151] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E9=97=AE?= =?UTF-8?q?=E7=AD=94=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d8d4291..5ac4149 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 @@ -93,7 +93,7 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("userid", userId); params.put("query",question); params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).toArray()); + params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body()); From 218a2499cd6d240face449b806d560b3f65d5165 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 8 May 2024 17:25:56 +0800 Subject: [PATCH 013/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E9=99=90?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98=E5=AE=8C=E6=88=90=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 11 +++++--- .../bigmodel/schedule/InteractiveSchedule.java | 31 +++++++++++++--------- 2 files changed, 25 insertions(+), 17 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 5ac4149..de8c3ac 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 @@ -21,6 +21,7 @@ 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; @@ -102,13 +103,15 @@ public class InteractiveServiceImpl implements IInteractiveService { return R.fail("远程调用大模型【发起问答】接口失败!"); } // 添加redis问题会话 - List asks = (List) redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(CollectionUtil.isEmpty(asks)){ - asks = Collections.singletonList(sessionId); + Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + if(ObjectUtil.isEmpty(json)){ + List asks = Collections.singletonList(sessionId); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); }else{ + List asks = JSONObject.parseArray(json.toString(),String.class); asks.add(sessionId); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,asks); return R.success("消息发送成功"); } 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 13b6344..13f7a93 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 @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.schedule; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; @@ -10,6 +11,7 @@ import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; @@ -70,21 +72,24 @@ public class InteractiveSchedule { XxlJobLogger.log("获取到答案:"+JSON.toJSONString(answerList)); answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { XxlJobLogger.log("开始获取"+answerVO.getSessionId()+"答案!"); - List asks = (List) redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - // 问题回答完成,去除redis问题标记 - if(answerVO.getStatus() == 0){ - if(CollectionUtil.isNotEmpty(asks) && asks.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); + Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + if(ObjectUtil.isNotEmpty(json)){ + List asks = JSONObject.parseArray(json.toString(),String.class); + // 问题回答完成,去除redis问题标记 + if(answerVO.getStatus() == 0){ + if(CollectionUtil.isNotEmpty(asks) && asks.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(session,message); + } + asks.remove(answerVO.getSessionId()); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(asks)); } - asks.remove(answerVO.getSessionId()); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,asks); - return; + }else{ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(session,message); } - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } From 9873e843d5a13cf7d36635aa8fad5ddc49edd09a Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 8 May 2024 17:28:46 +0800 Subject: [PATCH 014/151] =?UTF-8?q?add:=E6=99=BA=E8=83=BD=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 2 +- .../interactive/constants/ExtraTypeEnum.java | 20 +++++++++ .../interactive/constants/FuncRouteEnum.java | 1 + .../service/impl/ExtraResolveStrategyService.java | 51 ++++++++++++++++++++++ .../service/impl/InteractiveServiceImpl.java | 9 ++++ .../service/impl/JumpRouteJoinStrategy.java | 1 + 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 303a21e..c736e30 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -14,7 +14,7 @@ import java.io.Serializable; @ApiModel("响应内容") public class ExtraVO implements Serializable { - @ApiModelProperty("交互类型") + @ApiModelProperty("交互类型 1:打开页面,2:打开链接") private String type; @ApiModelProperty("若为弹窗,则返回路由") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java new file mode 100644 index 0000000..96a4661 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author: huangxing + * @Date: 2024/05/08 16:49 + */ +@AllArgsConstructor +public enum ExtraTypeEnum { + /**打开页面**/ + OPEN_PAGE("1"), + /**链接**/ + LINK("2") + ; + @Getter + private final String type; + +} 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 4d51364..7419128 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 @@ -14,6 +14,7 @@ import java.util.Optional; public enum FuncRouteEnum { OPEN_SCADA("open_scada","打开实时画面"), OPEN_VIDEO("open_video","打开视频监控"), + DIAGNOSE("diagnose","智能诊断") ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java new file mode 100644 index 0000000..ddd33ea --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -0,0 +1,51 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.ExtraTypeEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/05/08 16:19 + */ +@Service +public class ExtraResolveStrategyService { + + /** + * 解析DFP返回extra + * @param extraStr DFP返回extra + * @return 与前端交互extra + */ + public ExtraVO resolve(String extraStr) { + JSONObject extra = JSONObject.parseObject(extraStr); + String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse(""); + if(StringUtil.isNotBlank(functionCode)) { + FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); + switch (funcRouteEnum) { + case DIAGNOSE: + return this.resolveDiagnose(extra); + default: + break; + } + } + return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); + } + + private ExtraVO resolveDiagnose(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + String faultId = data.getString("fault_id"); + String faultName = data.getString("fault_name"); + result.setLabel(faultName); + // TODO 拼接诊断链接 + result.setType(ExtraTypeEnum.LINK.getType()); + return result; + } +} 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 de8c3ac..7a44495 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 @@ -12,6 +12,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,6 +20,7 @@ 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.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; @@ -64,6 +66,8 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; + private final ExtraResolveStrategyService extraResolveStrategyService; + @Value("${fdp.host}") private String fdpHost; @@ -125,6 +129,11 @@ public class InteractiveServiceImpl implements IInteractiveService { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); + JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> { + String[] extras = answerVO.getExtra(); + List extraList = Arrays.stream(extras).map(extra -> extraResolveStrategyService.resolve(extra)).map(JSON::toJSONString).collect(Collectors.toList()); + answerVO.setExtra(extraList.toArray(new String[extraList.size()])); + }); return JSONArray.parseArray(response.body(),AnswerVO.class); } 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 31ad197..b3e2fdf 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 @@ -48,6 +48,7 @@ public class JumpRouteJoinStrategy { private ExtraVO getScadaExtra(Map args,FunctionEntity function) { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); + Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); From 47270024152e0dc284f0a1257bc92ce2b1753c7f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 08:33:41 +0800 Subject: [PATCH 015/151] =?UTF-8?q?add:=E6=99=BA=E8=83=BD=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/feign/IStationVideoTypeClient.java | 5 +++ .../feign/IStationVideoTypeClientFallback.java | 5 +++ hzims-service/hzims-big-model/pom.xml | 10 +++++ .../bigmodel/schedule/InteractiveSchedule.java | 48 ++++++++++++++++++++-- .../bigmodel/schedule/XxlJobHandlerConstant.java | 6 +++ .../station/feign/StationVideoTypeClient.java | 15 ++++++- pom.xml | 3 +- 7 files changed, 86 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java index 46e26c4..89a9f98 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java @@ -4,6 +4,7 @@ import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -16,7 +17,11 @@ import java.util.List; public interface IStationVideoTypeClient { String API_PREFIX = "/feign/station/videoType"; String LIST_BY_STATION_ID = API_PREFIX + "/listByStationId"; + String LIST = API_PREFIX + "/list"; @PostMapping(LIST_BY_STATION_ID) List listByStationId(@RequestParam("stationId") String stationId); + + @GetMapping(LIST) + R> list(StationVideoTypeEntity req); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java index 24fb9db..3d43046 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java @@ -16,4 +16,9 @@ public class IStationVideoTypeClientFallback implements IStationVideoTypeClient log.info("调用{}接口失败",LIST_BY_STATION_ID); return new ArrayList(); } + + @Override + public R> list(StationVideoTypeEntity req) { + return R.fail("远程调用失败!"); + } } diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index ece5cf6..cedb16a 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -65,6 +65,16 @@ org.springblade blade-system-api + + + com.hnac.hzims + hzims-operational-api + 4.0.0-SNAPSHOT + + + com.hnac.hzinfo.data + hzinfo-data-sdk + 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 13f7a93..afd6df3 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 @@ -6,12 +6,22 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; +import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; +import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; +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.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; @@ -20,8 +30,10 @@ import org.springframework.web.socket.WebSocketSession; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Function; +import java.util.stream.Collectors; -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.GET_INTERACTIVE_RESULT; +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; /** * @Author: huangxing @@ -39,6 +51,12 @@ public class InteractiveSchedule { private final RedisTemplate redisTemplate; + private final IStationVideoTypeClient videoClient; + + private final ProjectClient projectClient; + + private final ScadaClient scadaClient; + private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; // @XxlJob(GET_INTERACTIVE_RESULT) @@ -65,8 +83,8 @@ public class InteractiveSchedule { // } @XxlJob(GET_INTERACTIVE_RESULT) - public ReturnT execute(String params) { - List sessionIds = InteractiveSessionManager.getSessionIds(); + public ReturnT getInteractiveResult(String params) { + List sessionIds = StringUtil.isNotBlank(params) && Func.isNotEmpty(params) ? Func.toStrList(",",params) : InteractiveSessionManager.getSessionIds(); XxlJobLogger.log("开始获取到sessionId:"+ String.join(",", sessionIds)); List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); XxlJobLogger.log("获取到答案:"+JSON.toJSONString(answerList)); @@ -93,4 +111,28 @@ public class InteractiveSchedule { }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } + + @XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) + public ReturnT synchronousVideoInstruct(String params) { + R> videoListR = videoClient.list(new StationVideoTypeEntity()); + if(videoListR.isSuccess()) { + List stationVideoList = videoListR.getData(); + //TODO 同步站点视频指令 + } + return ReturnT.SUCCESS; + } + + @XxlJob(SYNCHRONOUS_SCADA_INSTRUCT) + public ReturnT synchronousScadaInstruct(String params) { + Result> projectListR = projectClient.getProjectByAppId(); + if(projectListR.isSuccess()) { + List projectIds = projectListR.getData().stream().map(ProjectVO::getId).collect(Collectors.toList()); + Result> canvasListR = scadaClient.getCanvasList(projectIds); + if(canvasListR.isSuccess()) { + List canvasList = canvasListR.getData(); + //TODO 同步站点画面指令 + } + } + return ReturnT.SUCCESS; + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index 708d3e8..de73434 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -6,8 +6,14 @@ package com.hnac.hzims.bigmodel.schedule; */ public interface XxlJobHandlerConstant { + /**获取问答结果**/ String GET_INTERACTIVE_RESULT = "getInteractiveResult"; + /**同步视频指令**/ + String SYNCHRONOUS_VIDEO_INSTRUCT = "synchronousVideoInstruct"; + + String SYNCHRONOUS_SCADA_INSTRUCT = "synchronousScadaInstruct"; + String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java index 1692820..5dc44b2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java @@ -1,10 +1,15 @@ package com.hnac.hzims.operational.station.feign; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.common.support.utils.Condition; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import lombok.AllArgsConstructor; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -12,7 +17,6 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController -@RequestMapping("/feign/station/videoType") @AllArgsConstructor public class StationVideoTypeClient implements IStationVideoTypeClient { @@ -20,11 +24,18 @@ public class StationVideoTypeClient implements IStationVideoTypeClient { @ApiLog @Override - @PostMapping("/listByStationId") + @PostMapping(LIST_BY_STATION_ID) public List listByStationId(String stationId) { List result = stationVideoTypeService.list(new LambdaQueryWrapper(){{ eq(StationVideoTypeEntity::getStationId,stationId); }}); return result; } + + @Override + @GetMapping(LIST) + public R> list(StationVideoTypeEntity req) { + QueryWrapper queryWrapper = Condition.getQueryWrapper(req); + return R.data(stationVideoTypeService.list(queryWrapper)); + } } diff --git a/pom.xml b/pom.xml index 3339d22..47b1aaa 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,8 @@ com.hnac.hzinfo.data hzinfo-data-sdk - ${bladex.project.version} + + 5.1.1.RELEASE.fix.4 com.xuxueli From 59300d8cc90652dc0da477fae6236fb14f5436af Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 May 2024 08:46:04 +0800 Subject: [PATCH 016/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E9=99=90?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98=E5=AE=8C=E6=88=90=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/schedule/InteractiveSchedule.java | 58 +++++++--------------- 1 file changed, 18 insertions(+), 40 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 afd6df3..6d7298f 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 @@ -59,50 +59,28 @@ public class InteractiveSchedule { private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; -// @XxlJob(GET_INTERACTIVE_RESULT) -// public ReturnT execute(String params) { -// String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); -// Set keySet = redisTemplate.keys(resultKey + "*"); -// keySet.parallelStream().forEach(key -> { -// // 根据Key获取sessionId -// List keySplits = Func.toStrList(":", key); -// String sessionId = keySplits.get(2); -// // 查询websocket是否存在连接session -// WebSocketSession session = InteractiveSessionManager.get(sessionId); -// if(session == null) { -// return; -// } -// TextMessage message = new TextMessage(JSON.toJSONString(redisTemplate.opsForValue().get(key))); -// Boolean sendResult = wsService.sendMessage(sessionId, message); -// Assert.isTrue(sendResult, () -> { -// throw new ServiceException(key + "推送消息失败,推送消息体为:" + JSON.toJSONString(redisTemplate.opsForValue().get(key))); -// }); -// redisTemplate.delete(key); -// }); -// return ReturnT.SUCCESS; -// } - @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { - List sessionIds = StringUtil.isNotBlank(params) && Func.isNotEmpty(params) ? Func.toStrList(",",params) : InteractiveSessionManager.getSessionIds(); - XxlJobLogger.log("开始获取到sessionId:"+ String.join(",", sessionIds)); + Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + if(ObjectUtil.isEmpty(json)){ + XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!"); + return ReturnT.SUCCESS; + } + List sessionIds = JSONObject.parseArray(json.toString(),String.class); + if(CollectionUtil.isEmpty(sessionIds)){ + XxlJobLogger.log("问题都已经回答完毕!"); + return ReturnT.SUCCESS; + } List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); - XxlJobLogger.log("获取到答案:"+JSON.toJSONString(answerList)); answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { - XxlJobLogger.log("开始获取"+answerVO.getSessionId()+"答案!"); - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isNotEmpty(json)){ - List asks = JSONObject.parseArray(json.toString(),String.class); - // 问题回答完成,去除redis问题标记 - if(answerVO.getStatus() == 0){ - if(CollectionUtil.isNotEmpty(asks) && asks.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); - } - asks.remove(answerVO.getSessionId()); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(asks)); - } + XxlJobLogger.log("开始获取" + answerVO.getSessionId() + "答案!"); + // 问题回答完成,去除redis问题标记 + if(answerVO.getStatus() == 0){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(session,message); + sessionIds.remove(answerVO.getSessionId()); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); }else{ WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); From ce0179d38421885f1a5a993d59df8d62f993b97b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 May 2024 09:06:06 +0800 Subject: [PATCH 017/151] =?UTF-8?q?#=E5=88=A0=E9=99=A4=E5=AF=B9=E8=AF=9Dse?= =?UTF-8?q?ssionId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 + .../controller/InteractiveController.java | 8 ++++ .../interactive/service/IInteractiveService.java | 1 + .../service/impl/InteractiveServiceImpl.java | 44 +++++++++++++++------- .../bigmodel/schedule/InteractiveSchedule.java | 17 +++------ .../bigmodel/schedule/XxlJobHandlerConstant.java | 2 + 6 files changed, 49 insertions(+), 25 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 70a539d..122dbce 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -17,4 +17,6 @@ public class BigModelInvokeUrl { private String assistantStatus; + private String deleteAssistant; + } 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 5ca95c7..0ad5398 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 @@ -59,4 +59,12 @@ public class InteractiveController { return R.data(IdWorker.get32UUID()); } + @ApiOperation("删除对话sessionId") + @ApiOperationSupport(order = 5) + @GetMapping("/removeSessionId") + public R removeSessionId(@RequestParam(value = "sessionId") String sessionId) { + return R.data(interactiveService.removeSessionId(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 f497498..1eb206f 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 @@ -23,4 +23,5 @@ public interface IInteractiveService { Boolean authentication(String stationId, String userId, String funcCode); + Boolean removeSessionId(String sessionId); } 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 7a44495..3dc22fb 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 @@ -7,20 +7,16 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -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.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; @@ -35,14 +31,11 @@ import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; import java.util.*; +import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; -import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; /** * @Author: huangxing * @Date: 2024/04/26 14:51 @@ -71,8 +64,6 @@ public class InteractiveServiceImpl implements IInteractiveService { @Value("${fdp.host}") private String fdpHost; - private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; - @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); @@ -131,7 +122,7 @@ public class InteractiveServiceImpl implements IInteractiveService { }); JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> { String[] extras = answerVO.getExtra(); - List extraList = Arrays.stream(extras).map(extra -> extraResolveStrategyService.resolve(extra)).map(JSON::toJSONString).collect(Collectors.toList()); + List extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); answerVO.setExtra(extraList.toArray(new String[extraList.size()])); }); return JSONArray.parseArray(response.body(),AnswerVO.class); @@ -161,6 +152,33 @@ public class InteractiveServiceImpl implements IInteractiveService { return true; } + @Override + public Boolean removeSessionId(String sessionId) { + // 调用大模型删除对话 + Map params = new HashMap<>(); + params.put("id",sessionId); + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) + .body(JSON.toJSONString(params)).execute(); + if(response.getStatus() != HttpServletResponse.SC_OK) { + log.error("远程调用大模型【删除对话】接口失败!"); + throw new ServiceException("远程调用大模型【删除对话】接口失败!"); + } + // 移除对应reids中问题标记 + Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); + if(ObjectUtil.isEmpty(json)) { + return true; + } + List sessionIds = JSONObject.parseArray(json.toString(),String.class); + if(CollectionUtil.isEmpty(sessionIds)){ + return true; + } + if(sessionIds.contains(sessionId)){ + sessionIds.remove(sessionId); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(sessionIds)); + } + return true; + } + private List getStationPermissionsById(String userId) { R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { 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 6d7298f..5f3752f 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 @@ -19,9 +19,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; 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.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; @@ -30,7 +28,6 @@ import org.springframework.web.socket.WebSocketSession; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; -import java.util.function.Function; import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; @@ -74,19 +71,15 @@ public class InteractiveSchedule { List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); 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); // 问题回答完成,去除redis问题标记 if(answerVO.getStatus() == 0){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); sessionIds.remove(answerVO.getSessionId()); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); - }else{ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); } }, getAnswerPoolExecutor)); + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); return ReturnT.SUCCESS; } @@ -106,7 +99,7 @@ public class InteractiveSchedule { if(projectListR.isSuccess()) { List projectIds = projectListR.getData().stream().map(ProjectVO::getId).collect(Collectors.toList()); Result> canvasListR = scadaClient.getCanvasList(projectIds); - if(canvasListR.isSuccess()) { + if(canvasListR.isSuccess() && CollectionUtil.isNotEmpty(canvasListR.getData())) { List canvasList = canvasListR.getData(); //TODO 同步站点画面指令 } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index de73434..9d3cefd 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -16,4 +16,6 @@ public interface XxlJobHandlerConstant { String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; + String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + } From 1087377b2ece8c9933989d113f6f0e96a748bde0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 10:38:30 +0800 Subject: [PATCH 018/151] =?UTF-8?q?add:=E6=89=93=E5=BC=80=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E3=80=81=E5=A4=A7=E6=A8=A1=E5=9E=8B=E6=89=93=E5=BC=80?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=8C=87=E4=BB=A4=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 3 +- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 6 +- .../station/feign/IStationVideoTypeClient.java | 5 ++ .../feign/IStationVideoTypeClientFallback.java | 6 ++ .../bigmodel/configuration/BigModelInvokeUrl.java | 2 + .../interactive/service/IInteractiveService.java | 3 + .../interactive/service/IParamsService.java | 14 +++++ .../service/impl/InteractiveServiceImpl.java | 21 ++++++- .../service/impl/JumpRouteJoinStrategy.java | 2 - .../interactive/service/impl/ParamStrategy.java | 69 ++++++++++++++++++++++ .../service/impl/ParamsServiceImpl.java | 35 +++++++++++ .../bigmodel/interactive/vo/UpdateStationVO.java | 20 +++++++ .../bigmodel/interactive/vo/UpdateUsualVO.java | 25 ++++++++ .../bigmodel/schedule/InteractiveSchedule.java | 62 ++++++++++++++++++- .../station/feign/StationVideoTypeClient.java | 11 ++-- .../station/service/IStationVideoTypeService.java | 2 + .../service/impl/StationVideoTypeServiceImpl.java | 5 ++ 17 files changed, 277 insertions(+), 14 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 7d34a5d..abc1038 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -15,7 +15,8 @@ public interface FunctionConstants { @AllArgsConstructor enum TypeEnum { /**跳转页面**/ - JUMP("1") + JUMP("1"), + PARAMS("2") ; @Getter private String type; diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index c736e30..92174e8 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.util.Map; /** * @Author: huangxing @@ -14,7 +15,7 @@ import java.io.Serializable; @ApiModel("响应内容") public class ExtraVO implements Serializable { - @ApiModelProperty("交互类型 1:打开页面,2:打开链接") + @ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递") private String type; @ApiModelProperty("若为弹窗,则返回路由") @@ -26,4 +27,7 @@ public class ExtraVO implements Serializable { @ApiModelProperty("是否立即跳转") private boolean isImmediatelyJump = true; + @ApiModelProperty("附带参数") + private Map params; + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java index 89a9f98..b29e3e2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClient.java @@ -18,10 +18,15 @@ public interface IStationVideoTypeClient { String API_PREFIX = "/feign/station/videoType"; String LIST_BY_STATION_ID = API_PREFIX + "/listByStationId"; String LIST = API_PREFIX + "/list"; + String GET_BY_ID = API_PREFIX + "/getById"; + String GET_RTSP_ADDRESS_BY_ID = API_PREFIX + "/getRtspAddressById"; @PostMapping(LIST_BY_STATION_ID) List listByStationId(@RequestParam("stationId") String stationId); @GetMapping(LIST) R> list(StationVideoTypeEntity req); + + @GetMapping(GET_BY_ID) + R getById(@RequestParam Long id); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java index 3d43046..5ee3541 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationVideoTypeClientFallback.java @@ -21,4 +21,10 @@ public class IStationVideoTypeClientFallback implements IStationVideoTypeClient public R> list(StationVideoTypeEntity req) { return R.fail("远程调用失败!"); } + + @Override + public R getById(Long id) { + return R.fail("远程调用失败!"); + } + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 122dbce..c8248dd 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -19,4 +19,6 @@ public class BigModelInvokeUrl { private String deleteAssistant; + private String updateVideo; + } 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 1eb206f..b1d0573 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 @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Map; /** * @Author: huangxing @@ -19,6 +20,8 @@ public interface IInteractiveService { R ask(String question,String sessionId,String userId); + void updateVideo(Map request); + List getAnswerBySessionIds(String sessionIds); 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/IParamsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java new file mode 100644 index 0000000..aee914a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.hnac.hzims.bigmodel.entity.FunctionEntity; + +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/05/09 08:50 + */ +public interface IParamsService { + String dealJumpTypeFunction(FunctionEntity function, Map args); + +} 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 3dc22fb..2bb4ffc 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 @@ -11,6 +11,7 @@ import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; +import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -49,6 +50,8 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IJumpPageService jumpPageService; + private final IParamsService paramsService; + private final IFunctionService functionService; private final BigModelInvokeUrl bigModelInvokeUrl; @@ -72,11 +75,14 @@ public class InteractiveServiceImpl implements IInteractiveService { switch (typeEnum) { // 页面跳转 case JUMP: - String extra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); - Assert.isTrue(StringUtil.isNotBlank(extra) && Func.isNotEmpty(extra), () -> { + String jumpExtra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); + Assert.isTrue(StringUtil.isNotBlank(jumpExtra) && Func.isNotEmpty(jumpExtra), () -> { throw new ServiceException("解析" + function.getName() + "函数失败!"); }); - return R.data(extra); + return R.data(jumpExtra); + case PARAMS: + String paramExtra = paramsService.dealJumpTypeFunction(function, req.getFunctionArgs()); + return R.data(paramExtra); default: throw new ServiceException("函数解析失败!"); } @@ -111,6 +117,15 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override + public void updateVideo(Map request) { + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo()) + .body(JSON.toJSONString(request)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new ServiceException("远程调用大模型【更新实时监控】接口失败!"); + }); + } + + @Override public List getAnswerBySessionIds(String sessionIds) { Map params = new HashMap<>(); params.put("ids",Func.toStrList(",",sessionIds).toArray()); 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 b3e2fdf..9ff11d3 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 @@ -36,8 +36,6 @@ public class JumpRouteJoinStrategy { switch(routeEnum) { case OPEN_SCADA: return this.getScadaExtra(args,function); - case OPEN_VIDEO: - return this.getVideoExtra(args,function); default: break; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java new file mode 100644 index 0000000..d1928c3 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -0,0 +1,69 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/05/09 08:56 + */ +@Component +@Slf4j +@AllArgsConstructor +public class ParamStrategy { + + private final IStationVideoTypeClient videoClient; + + /** + * 解析发送参数方式函数 + * @param function 函数 + * @param args 大模型识别参数 + * @return 前端传参EXTRA + */ + public ExtraVO resolve(FunctionEntity function, Map args) { + FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); + if(Func.isNotEmpty(routeEnum)) { + switch(routeEnum) { + case OPEN_VIDEO: + return this.getVideoExtra(args); + default: + break; + } + } + return null; + } + + private ExtraVO getVideoExtra(Map args) { + // 跳转页面逻辑 + ExtraVO extraVO = new ExtraVO(); + String id = args.get("canvas_id"); + if(StringUtil.isNotBlank(id) && Func.isNotEmpty(id)) { + R videoR = videoClient.getById(Long.valueOf(id)); + if(videoR.isSuccess()) { + StationVideoTypeEntity video = videoR.getData(); + extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + Map params = new HashMap<>(); + params.put("videoHost", video.getVideoHost()); + params.put("pointCode", video.getPointCode()); + params.put("appKey", video.getAppKey()); + params.put("appSecret", video.getAppSecret()); + params.put("liveSourceAddress",video.getLiveSourceAddress()); + extraVO.setParams(params); + } + } + return extraVO; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java new file mode 100644 index 0000000..dd462c6 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.bigmodel.entity.FuncParamEntity; +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.interactive.service.IParamsService; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/05/09 08:51 + */ +@Service +@Slf4j +@AllArgsConstructor +public class ParamsServiceImpl implements IParamsService { + + private final ParamStrategy strategy; + + @Override + public String dealJumpTypeFunction(FunctionEntity function, Map args) { + // 跳转页面逻辑 + ExtraVO extraVO = strategy.resolve(function,args); + return JSON.toJSONString(extraVO); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java new file mode 100644 index 0000000..3ed167a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateStationVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 09:50 + */ +@Data +public class UpdateStationVO implements Serializable { + + /**站点ID**/ + private String id; + + /**站点名称**/ + private String name; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java new file mode 100644 index 0000000..88a9c73 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/UpdateUsualVO.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 09:53 + */ +@Data +public class UpdateUsualVO implements Serializable { + + /**站点ID**/ + @JSONField(name = "station_id") + private String stationId; + + /**业务ID**/ + private String id; + + /**业务名称**/ + private String name; + +} 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 5f3752f..a8cc9a7 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 @@ -4,9 +4,13 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; +import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.project.ProjectClient; @@ -25,7 +29,9 @@ import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; @@ -54,8 +60,33 @@ public class InteractiveSchedule { private final ScadaClient scadaClient; + private final IStationClient stationClient; + private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; +// @XxlJob(GET_INTERACTIVE_RESULT) +// public ReturnT execute(String params) { +// String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); +// Set keySet = redisTemplate.keys(resultKey + "*"); +// keySet.parallelStream().forEach(key -> { +// // 根据Key获取sessionId +// List keySplits = Func.toStrList(":", key); +// String sessionId = keySplits.get(2); +// // 查询websocket是否存在连接session +// WebSocketSession session = InteractiveSessionManager.get(sessionId); +// if(session == null) { +// return; +// } +// TextMessage message = new TextMessage(JSON.toJSONString(redisTemplate.opsForValue().get(key))); +// Boolean sendResult = wsService.sendMessage(sessionId, message); +// Assert.isTrue(sendResult, () -> { +// throw new ServiceException(key + "推送消息失败,推送消息体为:" + JSON.toJSONString(redisTemplate.opsForValue().get(key))); +// }); +// redisTemplate.delete(key); +// }); +// return ReturnT.SUCCESS; +// } + @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); @@ -85,11 +116,36 @@ public class InteractiveSchedule { @XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) public ReturnT synchronousVideoInstruct(String params) { + Map request = new HashMap<>(2); + // 获取站点列表 + R> stationsR = stationClient.list(new StationEntity()); + if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { + XxlJobLogger.log("获取站点列表失败!"); + return ReturnT.FAIL; + } + List updateStationList = stationsR.getData().stream().map(station -> { + UpdateStationVO stationVO = new UpdateStationVO(); + stationVO.setId(station.getCode()); + stationVO.setName(station.getName()); + return stationVO; + }).collect(Collectors.toList()); + request.put("stations", updateStationList); + // 获取视频列表 R> videoListR = videoClient.list(new StationVideoTypeEntity()); - if(videoListR.isSuccess()) { - List stationVideoList = videoListR.getData(); - //TODO 同步站点视频指令 + if(!videoListR.isSuccess() || CollectionUtil.isEmpty(videoListR.getData())) { + XxlJobLogger.log("获取视频列表失败!"); + return ReturnT.FAIL; } + List updateUsualList = videoListR.getData().stream().map(video -> { + UpdateUsualVO usualVO = new UpdateUsualVO(); + usualVO.setStationId(video.getStationId()); + usualVO.setId(String.valueOf(video.getId())); + usualVO.setName(video.getName()); + return usualVO; + }).collect(Collectors.toList()); + request.put("videos", updateUsualList); + // 同步指令 + interactiveService.updateVideo(request); return ReturnT.SUCCESS; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java index 5dc44b2..2aadb78 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationVideoTypeClient.java @@ -9,10 +9,7 @@ import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import lombok.AllArgsConstructor; import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -38,4 +35,10 @@ public class StationVideoTypeClient implements IStationVideoTypeClient { QueryWrapper queryWrapper = Condition.getQueryWrapper(req); return R.data(stationVideoTypeService.list(queryWrapper)); } + + @Override + @GetMapping(GET_BY_ID) + public R getById(@RequestParam Long id) { + return R.data(stationVideoTypeService.getById(id,0)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index 3862dff..24da4a6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -81,4 +81,6 @@ public interface IStationVideoTypeService extends BaseService deviceMap.get(c.getString("encodeDevIndexCode")))); } + @Override + public String getRtspAddressByVideo(StationVideoTypeEntity req) { + return null; + } + private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) { HikVideoAreaTreeVO parentTree = BeanUtil.copy(area,HikVideoAreaTreeVO.class); if(CollectionUtil.isNotEmpty(videoAreaMapByParent.get(area.getIndexCode()))) { From 1286108cc95c73d2cea82c26dd8438486a2597c7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 May 2024 11:41:57 +0800 Subject: [PATCH 019/151] =?UTF-8?q?#=E5=88=A0=E9=99=A4=E5=AF=B9=E8=AF=9Dse?= =?UTF-8?q?ssionId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/bigmodel/HzimsBigModelApplication.java | 13 ++++++++++--- .../hzims/bigmodel/configuration/BigModelInvokeUrl.java | 2 +- .../interactive/controller/InteractiveController.java | 2 +- .../interactive/service/impl/InteractiveServiceImpl.java | 9 +++++++-- .../hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 10 ++++++---- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java index 2709c09..0f09cc7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java @@ -1,28 +1,35 @@ package com.hnac.hzims.bigmodel; +import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.jwt.JwtUtil; import org.springblade.core.launch.BladeApplication; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.data.redis.core.RedisTemplate; import javax.annotation.Resource; +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; + @EnableBladeFeign(basePackages = {"org.springblade","com.hnac"}) @SpringCloudApplication @MapperScan("com.hnac.hzims.**.mapper.**") @ComponentScan(basePackages = {"com.hnac.hzims.bigmodel.*"}) @Resource @ComponentScan(basePackages = {"com.hnac.hzims.*"}) +@Slf4j public class HzimsBigModelApplication extends SpringBootServletInitializer { + public static void main(String[] args) { BladeApplication.run(BigModelConstants.APP_NAME, HzimsBigModelApplication.class, args); + RedisTemplate redisTemplate = JwtUtil.getRedisTemplate(); + redisTemplate.delete(HZIMS_BIGMODEL_ASK_KEY); + log.info("服务重启删除问题reids缓存:{}",HZIMS_BIGMODEL_ASK_KEY); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index c8248dd..2a50a77 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -17,7 +17,7 @@ public class BigModelInvokeUrl { private String assistantStatus; - private String deleteAssistant; + private String askAbort; private String updateVideo; 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 0ad5398..7739800 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 @@ -62,7 +62,7 @@ public class InteractiveController { @ApiOperation("删除对话sessionId") @ApiOperationSupport(order = 5) @GetMapping("/removeSessionId") - public R removeSessionId(@RequestParam(value = "sessionId") String sessionId) { + public R removeSessionId(@RequestParam(value = "id") String sessionId) { return R.data(interactiveService.removeSessionId(sessionId)); } 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 2bb4ffc..1222533 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 @@ -110,7 +110,9 @@ public class InteractiveServiceImpl implements IInteractiveService { redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); }else{ List asks = JSONObject.parseArray(json.toString(),String.class); - asks.add(sessionId); + if(!asks.contains(sessionId)){ + asks.add(sessionId); + } redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); } return R.success("消息发送成功"); @@ -137,6 +139,9 @@ public class InteractiveServiceImpl implements IInteractiveService { }); JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> { String[] extras = answerVO.getExtra(); + if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){ + return; + } List extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); answerVO.setExtra(extraList.toArray(new String[extraList.size()])); }); @@ -172,7 +177,7 @@ public class InteractiveServiceImpl implements IInteractiveService { // 调用大模型删除对话 Map params = new HashMap<>(); params.put("id",sessionId); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAskAbort()) .body(JSON.toJSONString(params)).execute(); if(response.getStatus() != HttpServletResponse.SC_OK) { log.error("远程调用大模型【删除对话】接口失败!"); 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 a8cc9a7..d1ed666 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 @@ -102,15 +102,17 @@ public class InteractiveSchedule { List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); 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); + if(sessionIds.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(session,message); + } // 问题回答完成,去除redis问题标记 if(answerVO.getStatus() == 0){ sessionIds.remove(answerVO.getSessionId()); } + redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); }, getAnswerPoolExecutor)); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); return ReturnT.SUCCESS; } From a187a5c7e070cb7519fe9a4d8344c6ce69900239 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 11:48:32 +0800 Subject: [PATCH 020/151] =?UTF-8?q?add:=E6=89=93=E5=BC=80=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E3=80=81=E5=A4=A7=E6=A8=A1=E5=9E=8B=E6=89=93=E5=BC=80?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=8C=87=E4=BB=A4=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 3 ++- .../interactive/constants/ExtraTypeEnum.java | 20 -------------------- .../service/impl/ExtraResolveStrategyService.java | 4 ++-- 3 files changed, 4 insertions(+), 23 deletions(-) delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index abc1038..958e3ba 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -16,7 +16,8 @@ public interface FunctionConstants { enum TypeEnum { /**跳转页面**/ JUMP("1"), - PARAMS("2") + LINK("2"), + PARAMS("3") ; @Getter private String type; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java deleted file mode 100644 index 96a4661..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ExtraTypeEnum.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @Author: huangxing - * @Date: 2024/05/08 16:49 - */ -@AllArgsConstructor -public enum ExtraTypeEnum { - /**打开页面**/ - OPEN_PAGE("1"), - /**链接**/ - LINK("2") - ; - @Getter - private final String type; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index ddd33ea..9affdac 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -2,8 +2,8 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.ExtraTypeEnum; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; @@ -45,7 +45,7 @@ public class ExtraResolveStrategyService { String faultName = data.getString("fault_name"); result.setLabel(faultName); // TODO 拼接诊断链接 - result.setType(ExtraTypeEnum.LINK.getType()); + result.setType(FunctionConstants.TypeEnum.LINK.getType()); return result; } } From 9e4c21749b4c2ebb5d8021e22684d71afbd0b395 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 15:59:09 +0800 Subject: [PATCH 021/151] =?UTF-8?q?fix:=E8=A7=A3=E6=9E=90=E5=A4=A7?= =?UTF-8?q?=E6=A8=A1=E5=9E=8Bextra=20bug=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/constants/FunctionConstants.java | 2 ++ .../bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 958e3ba..5a509dc 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -16,7 +16,9 @@ public interface FunctionConstants { enum TypeEnum { /**跳转页面**/ JUMP("1"), + /**链接**/ LINK("2"), + /**参数**/ PARAMS("3") ; @Getter 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 1222533..1914df5 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 @@ -137,7 +137,9 @@ public class InteractiveServiceImpl implements IInteractiveService { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); - JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> { + + List result = JSONArray.parseArray(response.body(), AnswerVO.class); + result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { String[] extras = answerVO.getExtra(); if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){ return; @@ -145,7 +147,7 @@ public class InteractiveServiceImpl implements IInteractiveService { List extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); answerVO.setExtra(extraList.toArray(new String[extraList.size()])); }); - return JSONArray.parseArray(response.body(),AnswerVO.class); + return result; } @Override From 9ce122e42a0e820bb63dd634104f5d0899bf696a Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 May 2024 16:09:33 +0800 Subject: [PATCH 022/151] =?UTF-8?q?#=E5=90=8C=E6=AD=A5=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E7=94=BB=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 + .../interactive/service/IInteractiveService.java | 2 + .../service/impl/InteractiveServiceImpl.java | 11 +++++ .../bigmodel/schedule/InteractiveSchedule.java | 48 ++++++++++++++++++---- .../service/impl/RealMonitorServiceImpl.java | 2 +- 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 2a50a77..d2f0bd9 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -21,4 +21,6 @@ public class BigModelInvokeUrl { private String updateVideo; + private String updateCanvas; + } 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 b1d0573..9788cd0 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 @@ -22,6 +22,8 @@ public interface IInteractiveService { void updateVideo(Map request); + Boolean updateCanvas(Map request); + List getAnswerBySessionIds(String sessionIds); 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 1914df5..bb01d93 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 @@ -128,6 +128,17 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override + public Boolean updateCanvas(Map request) { + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateCanvas()) + .body(JSON.toJSONString(request)).execute(); + if (response.getStatus() == HttpServletResponse.SC_OK) { + return true; + } + log.error("远程调用大模型【更新实时画面】接口失败!"); + return false; + } + + @Override public List getAnswerBySessionIds(String sessionIds) { Map params = new HashMap<>(); params.put("ids",Func.toStrList(",",sessionIds).toArray()); 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 d1ed666..9210d2a 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 @@ -24,7 +24,9 @@ import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -32,6 +34,7 @@ import org.springframework.web.socket.WebSocketSession; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; @@ -108,7 +111,7 @@ public class InteractiveSchedule { wsService.sendMessage(session,message); } // 问题回答完成,去除redis问题标记 - if(answerVO.getStatus() == 0){ + if(answerVO.getRunning() == 0){ sessionIds.remove(answerVO.getSessionId()); } redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); @@ -153,15 +156,42 @@ public class InteractiveSchedule { @XxlJob(SYNCHRONOUS_SCADA_INSTRUCT) public ReturnT synchronousScadaInstruct(String params) { - Result> projectListR = projectClient.getProjectByAppId(); - if(projectListR.isSuccess()) { - List projectIds = projectListR.getData().stream().map(ProjectVO::getId).collect(Collectors.toList()); - Result> canvasListR = scadaClient.getCanvasList(projectIds); - if(canvasListR.isSuccess() && CollectionUtil.isNotEmpty(canvasListR.getData())) { - List canvasList = canvasListR.getData(); - //TODO 同步站点画面指令 - } + // 查询项目数据 + Result> projects = projectClient.getProjectByAppId(); + if(!projects.isSuccess() || CollectionUtil.isEmpty(projects.getData())){ + return ReturnT.SUCCESS; + } + // 请求fdp同步实时画面方法参数定义 + Map param = new HashMap<>(2); + List stations = projects.getData().stream().map(station -> { + UpdateStationVO updateStation = new UpdateStationVO(); + updateStation.setId(station.getId()); + updateStation.setName(station.getName()); + return updateStation; + }).collect(Collectors.toList()); + param.put("stations", stations); + // 查询画面信息 + Result> canvas = scadaClient.getCanvasList(projects.getData().stream().map(ProjectVO::getId).collect(Collectors.toList())); + if(!canvas.isSuccess() || CollectionUtil.isEmpty(canvas.getData())) { + return ReturnT.SUCCESS; } + List updateUsuals = canvas.getData().stream().map(canva -> { + UpdateUsualVO usualVO = new UpdateUsualVO(); + usualVO.setStationId(canva.getProjectId()); + usualVO.setName(canva.getName()); + // 画面id = + String id = Optional.of(canva.getPicSource()).map(String::valueOf).orElse("") + "^" + + Optional.ofNullable(canva.getContext()).orElse("") + "^" + + Optional.ofNullable(canva.getStationNum()).orElse("") + "^" + + Optional.ofNullable(canva.getProjectId()).orElse("") + "^" + + Optional.ofNullable(canva.getTaskId()).map(String::valueOf).orElse("") + "^" + + Optional.ofNullable(canva.getName()).orElse("") + "^" + + Optional.ofNullable(canva.getId()).map(String::valueOf).orElse("") + "^"; + usualVO.setId(id); + return usualVO; + }).collect(Collectors.toList()); + param.put("canvases", updateUsuals); + Boolean status = interactiveService.updateCanvas(param); return ReturnT.SUCCESS; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index e6aed35..c7a92e7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -343,7 +343,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } if(station.getWaterLevelMax() < station.getWaterLevel()){ station.setWaterColor(2); - }else if((station.getWaterLevel() / station.getWaterLevelMax()) > 0.9){ + }else if((station.getWaterLevel() / station.getWaterLevelMax()) > 0.8){ station.setWaterColor(1); } } From 615355d72bacbdd7fdc9ec56b3bae897c493f461 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 17:13:08 +0800 Subject: [PATCH 023/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 3 +- .../interactive/constants/SelectionVO.java | 20 +++++++++++ .../interactive/constants/StationSelectionVO.java | 12 +++++++ .../hzims/bigmodel/interactive/vo/ExtraVO.java | 10 +++++- .../interactive/constants/FuncRouteEnum.java | 3 +- .../service/impl/ExtraResolveStrategyService.java | 42 ++++++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 5a509dc..7114de1 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -19,7 +19,8 @@ public interface FunctionConstants { /**链接**/ LINK("2"), /**参数**/ - PARAMS("3") + PARAMS("3"), + CHOOSE("4") ; @Getter private String type; diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java new file mode 100644 index 0000000..a7a271f --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:30 + */ +@Data +public class SelectionVO implements Serializable { + + /**选项ID**/ + private String id; + + /**选项名称**/ + private String name; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java new file mode 100644 index 0000000..d67a829 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.Data; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:32 + */ +@Data +public class StationSelectionVO extends SelectionVO { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 92174e8..dbf1a86 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -1,10 +1,13 @@ package com.hnac.hzims.bigmodel.interactive.vo; +import com.hnac.hzims.bigmodel.interactive.constants.SelectionVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import net.sf.jsqlparser.statement.select.Select; import java.io.Serializable; +import java.util.List; import java.util.Map; /** @@ -15,7 +18,7 @@ import java.util.Map; @ApiModel("响应内容") public class ExtraVO implements Serializable { - @ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递") + @ApiModelProperty("交互类型 1:打开页面,2:打开链接,3:参数传递,4:完善选项") private String type; @ApiModelProperty("若为弹窗,则返回路由") @@ -30,4 +33,9 @@ public class ExtraVO implements Serializable { @ApiModelProperty("附带参数") private Map params; + @ApiModelProperty("是否为特殊函数") + private boolean isSpecial; + + @ApiModelProperty("选项") + private List selection; } 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 7419128..724f97e 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 @@ -14,7 +14,8 @@ import java.util.Optional; public enum FuncRouteEnum { OPEN_SCADA("open_scada","打开实时画面"), OPEN_VIDEO("open_video","打开视频监控"), - DIAGNOSE("diagnose","智能诊断") + DIAGNOSE("diagnose","智能诊断"), + CHOOSE_STATION("choose_station","选择站点"), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 9affdac..c16cdb6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -1,23 +1,36 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /** * @Author: huangxing * @Date: 2024/05/08 16:19 */ @Service +@AllArgsConstructor public class ExtraResolveStrategyService { + private final IStationClient stationClient; + /** * 解析DFP返回extra * @param extraStr DFP返回extra @@ -31,6 +44,8 @@ public class ExtraResolveStrategyService { switch (funcRouteEnum) { case DIAGNOSE: return this.resolveDiagnose(extra); + case CHOOSE_STATION: + return this.resolveChooseStation(extra); default: break; } @@ -48,4 +63,31 @@ public class ExtraResolveStrategyService { result.setType(FunctionConstants.TypeEnum.LINK.getType()); return result; } + + /** + * + * @param extra + * @return + */ + private ExtraVO resolveChooseStation(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("stations")) { + List stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); + List selectionList = stations.stream().map(stationId -> { + StationSelectionVO selectionVO = new StationSelectionVO(); + R stationR = stationClient.getStationByCode(stationId); + if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) { + selectionVO.setId(stationId); + selectionVO.setName(stationR.getData().getName()); + } + return selectionVO; + }).collect(Collectors.toList()); + result.setSelection(selectionList); + result.setSpecial(true); + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + } + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + return result; + } } From 2499c3bbcd608e6fe871361d935b728694f33b25 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 9 May 2024 21:00:52 +0800 Subject: [PATCH 024/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 2 +- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 ++ .../interactive/service/IInteractiveService.java | 2 ++ .../service/impl/InteractiveServiceImpl.java | 22 ++++++++++++++ .../service/impl/JumpRouteJoinStrategy.java | 18 +----------- .../websocket/handler/InteractiveHandler.java | 34 +++++++++++++++++++--- 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index dbf1a86..ab8578b 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -28,7 +28,7 @@ public class ExtraVO implements Serializable { private String label; @ApiModelProperty("是否立即跳转") - private boolean isImmediatelyJump = true; + private boolean isImmediatelyJump = false; @ApiModelProperty("附带参数") private Map params; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index d2f0bd9..0456fa2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -15,6 +15,8 @@ public class BigModelInvokeUrl { private String assistantAsk; + private String assistantSpecialAsk; + private String assistantStatus; private String askAbort; 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 9788cd0..f740a40 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 @@ -20,6 +20,8 @@ public interface IInteractiveService { R ask(String question,String sessionId,String userId); + R specialAsk(String sessionId,String userId,Map extra); + void updateVideo(Map request); Boolean updateCanvas(Map request); 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 bb01d93..48941f4 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 @@ -103,6 +103,11 @@ public class InteractiveServiceImpl implements IInteractiveService { log.error("远程调用大模型【发起问答】接口失败!"); return R.fail("远程调用大模型【发起问答】接口失败!"); } + this.addQuestionSessionId(sessionId); + return R.success("消息发送成功"); + } + + private void addQuestionSessionId(String sessionId) { // 添加redis问题会话 Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); if(ObjectUtil.isEmpty(json)){ @@ -115,6 +120,23 @@ public class InteractiveServiceImpl implements IInteractiveService { } redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); } + } + + @Override + public R specialAsk(String sessionId, String userId, Map extra) { + Map params = new HashMap<>(); + params.put("id",sessionId); + params.put("userid", userId); + params.put("extra",extra); + params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk()) + .body(JSON.toJSONString(params)).execute(); + if(response.getStatus() != HttpServletResponse.SC_OK) { + log.error("远程调用大模型【发起特殊问答】接口失败!"); + return R.fail("远程调用大模型【发起特殊问答】接口失败!"); + } + this.addQuestionSessionId(sessionId); return R.success("消息发送成功"); } 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 9ff11d3..907266e 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 @@ -46,7 +46,7 @@ public class JumpRouteJoinStrategy { private ExtraVO getScadaExtra(Map args,FunctionEntity function) { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); - + extraVO.setImmediatelyJump(true); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); @@ -79,15 +79,6 @@ 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 大模型解析参数 @@ -100,13 +91,6 @@ public class JumpRouteJoinStrategy { return this.resolve(params,keys); } - private Map videoResolve(Map args) { - 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); - } - private Map resolve(String paramsStr,String... keys) { Map result = new HashMap<>(); List params = Func.toStrList("\\^", paramsStr); 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 6c030fb..1a11faa 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 @@ -2,11 +2,14 @@ package com.hnac.hzims.bigmodel.websocket.handler; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; import org.springframework.util.Assert; import org.springframework.web.socket.CloseStatus; @@ -57,12 +60,35 @@ public class InteractiveHandler extends TextWebSocketHandler { throw new RuntimeException(e); } }else { - // 发送问题 - String context = messageJSON.getString("context"); - String userId = messageJSON.getString("userId"); + String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); + this.handleMessage(messageJSON,sessionId); + } + } + + private void handleMessage(JSONObject messageContext,String sessionId) { + Boolean isSpecial = messageContext.getBoolean("isSpecial"); + String context = messageContext.getString("context"); + String userId = messageContext.getString("userId"); + if(Func.isEmpty(isSpecial) || !isSpecial) { IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - R askResult = interactiveService.ask(context, InteractiveSessionManager.getEntryBySession(session).getKey(), userId); + R askResult = interactiveService.ask(context, sessionId, userId); log.info("返回结果为:"+ JSON.toJSONString(askResult)); } + else { + String funcCode = messageContext.getString("func"); + FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); + switch (funcEnum) { + case CHOOSE_STATION: + this.handleChooseStation(messageContext); + break; + default: + break; + } + } + } + + private void handleChooseStation(JSONObject messageContext) { + StationSelectionVO selectionVO = messageContext.getObject("selection",StationSelectionVO.class); + } } From 41b6932a4c75e4c046c73e21e42d4d32e9bebe36 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 May 2024 21:05:40 +0800 Subject: [PATCH 025/151] =?UTF-8?q?#=E5=90=8C=E6=AD=A5=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E7=94=BB=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 2 -- 1 file changed, 2 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 9210d2a..7af5118 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 @@ -65,8 +65,6 @@ public class InteractiveSchedule { private final IStationClient stationClient; - private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; - // @XxlJob(GET_INTERACTIVE_RESULT) // public ReturnT execute(String params) { // String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); From d89c8cd5a0b4c56cde0d053db8570a856cac4f1b Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 10 May 2024 09:20:23 +0800 Subject: [PATCH 026/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/handler/InteractiveHandler.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 1a11faa..093eb06 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 @@ -18,6 +18,7 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; +import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -67,9 +68,9 @@ public class InteractiveHandler extends TextWebSocketHandler { private void handleMessage(JSONObject messageContext,String sessionId) { Boolean isSpecial = messageContext.getBoolean("isSpecial"); - String context = messageContext.getString("context"); - String userId = messageContext.getString("userId"); if(Func.isEmpty(isSpecial) || !isSpecial) { + String context = messageContext.getString("context"); + String userId = messageContext.getString("userId"); IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); R askResult = interactiveService.ask(context, sessionId, userId); log.info("返回结果为:"+ JSON.toJSONString(askResult)); @@ -79,7 +80,7 @@ public class InteractiveHandler extends TextWebSocketHandler { FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); switch (funcEnum) { case CHOOSE_STATION: - this.handleChooseStation(messageContext); + this.handleChooseStation(messageContext,sessionId); break; default: break; @@ -87,8 +88,17 @@ public class InteractiveHandler extends TextWebSocketHandler { } } - private void handleChooseStation(JSONObject messageContext) { + private void handleChooseStation(JSONObject messageContext,String sessionId) { + IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + String userId = messageContext.getString("userId"); + String funcCode = messageContext.getString("funcCode"); StationSelectionVO selectionVO = messageContext.getObject("selection",StationSelectionVO.class); - + JSONObject data = new JSONObject(); + data.put("station_id",selectionVO.getId()); + data.put("station_name",selectionVO.getName()); + Map extra = new HashMap<>(2); + extra.put("func",funcCode); + extra.put("data",data); + interactiveService.specialAsk(sessionId,userId,extra); } } From 15b6b41bb6fb5dff5ad10a6faf875363917fa9d6 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 10 May 2024 11:50:51 +0800 Subject: [PATCH 027/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java | 3 +++ .../interactive/service/impl/ExtraResolveStrategyService.java | 1 + .../bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 4 ++-- .../main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java | 2 +- .../com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index ab8578b..cda702f 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -27,6 +27,9 @@ public class ExtraVO implements Serializable { @ApiModelProperty("链接显示文字") private String label; + @ApiModelProperty("函数编号") + private String funcCode; + @ApiModelProperty("是否立即跳转") private boolean isImmediatelyJump = false; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index c16cdb6..6c19dc0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -84,6 +84,7 @@ public class ExtraResolveStrategyService { return selectionVO; }).collect(Collectors.toList()); result.setSelection(selectionList); + result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode()); result.setSpecial(true); result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); } 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 48941f4..aee1bda 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 @@ -173,11 +173,11 @@ public class InteractiveServiceImpl implements IInteractiveService { List result = JSONArray.parseArray(response.body(), AnswerVO.class); result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { - String[] extras = answerVO.getExtra(); + Object[] extras = answerVO.getExtra(); if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){ return; } - List extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); + List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); answerVO.setExtra(extraList.toArray(new String[extraList.size()])); }); return result; 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 3b1ac38..ec2760d 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 @@ -45,6 +45,6 @@ public class AnswerVO implements Serializable { private String answer; @ApiModelProperty("其它调用的参数") - private String[] extra; + private Object[] extra; } 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 093eb06..3a25314 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 @@ -76,7 +76,7 @@ public class InteractiveHandler extends TextWebSocketHandler { log.info("返回结果为:"+ JSON.toJSONString(askResult)); } else { - String funcCode = messageContext.getString("func"); + String funcCode = messageContext.getString("funcCode"); FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); switch (funcEnum) { case CHOOSE_STATION: From ea46d211fe694a9b8f943d4aac8a8107265e8538 Mon Sep 17 00:00:00 2001 From: RnhaiWang <393727820@qq.com> Date: Fri, 10 May 2024 14:57:42 +0800 Subject: [PATCH 028/151] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E9=81=A5=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzinfo/inspect/ai/vo/RemoteControlDTO.java | 31 ++++++++++ .../inspect/ai/controller/RobotController.java | 12 ++++ .../hzinfo/inspect/ai/service/IRobotService.java | 6 ++ .../inspect/ai/service/impl/RobotServiceImpl.java | 67 ++++++++++++++++------ .../hzinfo/inspect/task/mapper/TaskMapper.java | 3 + .../hnac/hzinfo/inspect/task/mapper/TaskMapper.xml | 13 +++++ .../hzinfo/inspect/task/service/ITaskService.java | 2 + .../inspect/task/service/impl/TaskServiceImpl.java | 5 ++ 8 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java new file mode 100644 index 0000000..4c5cc15 --- /dev/null +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java @@ -0,0 +1,31 @@ +package com.hnac.hzinfo.inspect.ai.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Map; + +@Data +public class RemoteControlDTO { + + @ApiModelProperty("站点编号") + @NotBlank + private String stationCode; + + @ApiModelProperty("设备编码") + @NotBlank + private String deviceCode; + + @ApiModelProperty("功能标识") + @NotBlank + private String signage; + + @ApiModelProperty("参数列表") + @NotBlank + private Map params; + + @ApiModelProperty("机器码") + @NotBlank + private String machineCode; +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java index 740a04d..580aa59 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; +import com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotAiReturnData; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotServerTaskParam; @@ -68,6 +69,8 @@ public class RobotController extends BladeController { @Operate(label = "查看机器人详情",type = BusinessType.QUERY,ignore = false) public R detail(RobotEntity st_robot) { RobotEntity detail = st_robotService.getOne(Condition.getQueryWrapper(st_robot)); + User user = UserCache.getUser(detail.getUserId()); + detail.setUserName(Optional.ofNullable(user).map(User::getName).orElse(null)); return R.data(detail); } @@ -177,4 +180,13 @@ public class RobotController extends BladeController { @RequestParam @ApiParam("结束时间") String endTime, Query query) { return R.data(st_robotService.getRobotSoeData(robotCode,startTime,endTime,query)); } + + + @PostMapping("/remoteControl") + @ApiOperationSupport(order = 13) + @ApiOperation(value = "机器人远程控制", notes = "机器人远程控制") + @Operate(label = "机器人远程控制",type = BusinessType.UPDATE,risk = Risk.HIGH,ignore = false) + public R sendToDevice(@RequestBody RemoteControlDTO dto) { + return R.data(st_robotService.remoteControl(dto)); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java index ca7fc40..20f9d79 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java @@ -1,8 +1,10 @@ package com.hnac.hzinfo.inspect.ai.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; +import com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; import com.hnac.hzinfo.inspect.ai.vo.RobotVO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO; @@ -42,4 +44,8 @@ public interface IRobotService extends BaseService { Map> getRealDataByRobotCode(String robotCode); IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query); + + Object remoteControl(RemoteControlDTO dto); + + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java index aa30f6b..f8313af 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java @@ -1,31 +1,31 @@ package com.hnac.hzinfo.inspect.ai.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; -import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; -import com.hnac.hzinfo.datasearch.device.IDeviceClient; -import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; -import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; +import com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; import com.hnac.hzinfo.inspect.ai.vo.RobotVO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; import com.hnac.hzinfo.inspect.ai.wrapper.RobotWrapper; import com.hnac.hzinfo.inspect.constants.ParamConstants; -import com.hnac.hzinfo.log.annotation.Business; -import com.hnac.hzinfo.log.annotation.Operate; -import com.hnac.hzinfo.log.contants.BusinessType; +import com.hnac.hzinfo.inspect.task.TaskContants; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.service.ITaskService; import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.control.ControlClient; +import com.hnac.hzinfo.sdk.v5.control.dto.ControlDTO; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.po.DeviceRealDataPO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.RealDataRedisVO; import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -35,20 +35,14 @@ import com.hnac.hzinfo.inspect.ai.mapper.RobotMapper; import com.hnac.hzinfo.inspect.ai.service.IRobotService; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.cache.ParamCache; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; +import java.util.*; import java.util.stream.Collectors; /** @@ -62,8 +56,9 @@ import java.util.stream.Collectors; public class RobotServiceImpl extends BaseServiceImpl implements IRobotService { private final DeviceClient deviceClient; - private final IAnalyseDataSearchClient analyseDataSearchClient; private final DeviceDataClient deviceDataClient; + private final ControlClient controlClient; + private final ProjectClient projectClient; /** * 根据用户id 获取 机器人信息 @@ -87,6 +82,14 @@ public class RobotServiceImpl extends BaseServiceImpl throw new ServiceException("该机器人已经创建过设备实例,无需再创建!"); } else { + Result> projectVOResult = projectClient.getProjectIds(Collections.singletonList(device.getStationCode())); + Assert.isTrue(projectVOResult.isSuccess(),() -> { + throw new ServiceException("获取站点信息失败!"); + }); + List projectVOList = projectVOResult.getData(); + if (projectVOList==null||projectVOList.isEmpty()){ + throw new ServiceException("数据平台不存在该站点信息!"); + } String modelSignage = ParamCache.getValue(ParamConstants.ROBOT_MODEL_CODE); device.setModelSignage(Func.isNotEmpty(device.getModelSignage()) ? device.getModelSignage() : modelSignage); VirtualDeviceDTO req = BeanUtil.copy(device, VirtualDeviceDTO.class); @@ -151,5 +154,31 @@ public class RobotServiceImpl extends BaseServiceImpl return result; } + @Override + public Object remoteControl(RemoteControlDTO dto) { + ControlDTO controlDTO=new ControlDTO(); + BeanUtil.copy(dto,controlDTO); + controlDTO.setProjectId(dto.getStationCode()); + controlDTO.setOperator(String.valueOf(AuthUtil.getUserId())); + Result result = controlClient.sendToDevice(controlDTO); + Assert.isTrue(result.isSuccess(),()->{ + throw new ServiceException("修改遥控失败!"); + }); + + RobotEntity robotEntity = this.getOne(new LambdaQueryWrapper().eq(RobotEntity::getCode, dto.getDeviceCode())); + + //机器人停机任务置为未完成 + List taskStatus = Arrays.asList(TaskContants.TaskStatusEnum.INIT_STATUS.getStatus(), TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus(), TaskContants.TaskStatusEnum.PAUSE_STATUS.getStatus()); + ITaskService taskService = SpringUtil.getBean(ITaskService.class); + List robotTaskEntities=taskService.getListByUserIdAndStatus(robotEntity.getUserId(),taskStatus,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + if (!robotTaskEntities.isEmpty()){ + robotTaskEntities.forEach(item->item.setStatus(Integer.valueOf(TaskContants.TaskStatusEnum.UNFINISH_STATUS.getStatus()))); + taskService.saveOrUpdateBatch(robotTaskEntities); + } + return result.getData(); + } + + + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java index 932cc16..ebfa615 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java @@ -1,5 +1,6 @@ package com.hnac.hzinfo.inspect.task.mapper; +import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; import com.hnac.hzinfo.inspect.task.dto.TaskDTO; import com.hnac.hzinfo.inspect.task.vo.TaskCountVO; import com.hnac.hzinfo.inspect.task.vo.TaskOfflineVO; @@ -127,4 +128,6 @@ public interface TaskMapper extends UserDataScopeBaseMapper { List getTaskData(@Param("userIds") List userIds, @Param("currentDate") String currentDate); List getSameDayTask(@Param("taskIds") List taskIds, @Param("status") String status,@Param("startDate") String startDate,@Param("endDate") String endDate); + + List getListByUserIdAndStatus(Long userId, String autoVideo, List taskStatus,String time); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml index 554313c..432259f 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml @@ -452,4 +452,17 @@ + + diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java index df61c52..5dd62f1 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java @@ -192,4 +192,6 @@ public interface ITaskService extends BaseService { List getTaskListStatistics(String startTime, String endTime,Long deptId); List exportTaskList(TaskDTO task); + + List getListByUserIdAndStatus(Long userId, List taskStatus,String time); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index c9d29b8..a18d489 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -1188,4 +1188,9 @@ public class TaskServiceImpl extends BaseServiceImpl imp return voteChartVo; } + @Override + public List getListByUserIdAndStatus(Long userId, List taskStatus,String time) { + return this.baseMapper.getListByUserIdAndStatus(userId, PlanContants.InspectTypeEnum.ROBOT.getVal(),taskStatus,time); + } + } From 69a60eb94eeae068fdeb815305c82f1fda6bb06c Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 10 May 2024 15:06:56 +0800 Subject: [PATCH 029/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/service/impl/InteractiveServiceImpl.java | 9 +++++---- .../java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java | 2 +- 2 files changed, 6 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 aee1bda..0ac3ff3 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 @@ -13,6 +13,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -170,15 +171,15 @@ public class InteractiveServiceImpl implements IInteractiveService { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); - + XxlJobLogger.log("接收到答案:"+JSON.toJSONString(response.body())); List result = JSONArray.parseArray(response.body(), AnswerVO.class); result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { - Object[] extras = answerVO.getExtra(); - if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){ + Object[] extras = answerVO.getExtras(); + if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){ return; } List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); - answerVO.setExtra(extraList.toArray(new String[extraList.size()])); + answerVO.setExtras(extraList.toArray(new String[extraList.size()])); }); return result; } 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 ec2760d..712b2bf 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 @@ -45,6 +45,6 @@ public class AnswerVO implements Serializable { private String answer; @ApiModelProperty("其它调用的参数") - private Object[] extra; + private Object[] extras; } From 3b30a04a0cc6e0453548d74161c7c1a1f6179e41 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 10 May 2024 15:16:42 +0800 Subject: [PATCH 030/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index d1928c3..ef081db 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -56,6 +56,7 @@ public class ParamStrategy { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); Map params = new HashMap<>(); + params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); params.put("pointCode", video.getPointCode()); params.put("appKey", video.getAppKey()); From b1d321debbca2467b91efd84406d473744695e48 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 10 May 2024 15:38:17 +0800 Subject: [PATCH 031/151] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E9=80=89=E9=A1=B9=E9=97=AE=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExtraResolveStrategyService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 6c19dc0..45a7d25 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -16,6 +16,7 @@ import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -56,11 +57,14 @@ public class ExtraResolveStrategyService { private ExtraVO resolveDiagnose(Map extra) { ExtraVO result = new ExtraVO(); JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - String faultId = data.getString("fault_id"); - String faultName = data.getString("fault_name"); - result.setLabel(faultName); - // TODO 拼接诊断链接 - result.setType(FunctionConstants.TypeEnum.LINK.getType()); + Map params = new HashMap<>(5); + params.put("faultId",data.getString("fault_id")); + params.put("name",data.getString("fault_name")); + params.put("station",data.getString("station_id")); + params.put("fdpDeviceName",data.getString("device_name")); + params.put("fdpOrd",data.getString("ord")); + result.setParams(params); + result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); return result; } From c9026a3f800d94039c1dae0b873a351df43f684a Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 11 May 2024 11:24:57 +0800 Subject: [PATCH 032/151] =?UTF-8?q?fix:=E8=BF=94=E5=9B=9E=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=93=8D=E5=BA=94=E5=AF=B9=E8=B1=A1extras=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0funcCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 ++ .../interactive/service/IInteractiveService.java | 2 ++ .../service/impl/ExtraResolveStrategyService.java | 1 + .../service/impl/InteractiveServiceImpl.java | 9 +++++++++ .../service/impl/JumpRouteJoinStrategy.java | 1 + .../interactive/service/impl/ParamStrategy.java | 1 + .../bigmodel/schedule/InteractiveSchedule.java | 21 +++++++++++++++++++++ .../bigmodel/schedule/XxlJobHandlerConstant.java | 2 ++ 8 files changed, 39 insertions(+) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 0456fa2..7f8d6d5 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -23,6 +23,8 @@ public class BigModelInvokeUrl { private String updateVideo; + private String updateFault; + private String updateCanvas; } 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 f740a40..b85ad2f 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 @@ -26,6 +26,8 @@ public interface IInteractiveService { Boolean updateCanvas(Map request); + void updateFault(Map request); + List getAnswerBySessionIds(String sessionIds); 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/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 45a7d25..8419dee 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -64,6 +64,7 @@ public class ExtraResolveStrategyService { params.put("fdpDeviceName",data.getString("device_name")); params.put("fdpOrd",data.getString("ord")); result.setParams(params); + result.setFuncCode(FuncRouteEnum.DIAGNOSE.getFuncCode()); result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); return result; } 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 0ac3ff3..d70bcd4 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 @@ -162,6 +162,15 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override + public void updateFault(Map request) { + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateFault()) + .body(JSON.toJSONString(request)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new ServiceException("远程调用大模型【更新故障列表】接口失败!"); + }); + } + + @Override public List getAnswerBySessionIds(String sessionIds) { Map params = new HashMap<>(); params.put("ids",Func.toStrList(",",sessionIds).toArray()); 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 907266e..e3b7f55 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 @@ -47,6 +47,7 @@ public class JumpRouteJoinStrategy { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); + extraVO.setFuncCode(FuncRouteEnum.OPEN_SCADA.getFuncCode()); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index ef081db..6e9cd62 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -55,6 +55,7 @@ public class ParamStrategy { if(videoR.isSuccess()) { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); Map params = new HashMap<>(); params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); 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 7af5118..629d287 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 @@ -192,4 +192,25 @@ public class InteractiveSchedule { Boolean status = interactiveService.updateCanvas(param); return ReturnT.SUCCESS; } + + //@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) String params + @Scheduled(cron = "0/10 * * * * ?") + public ReturnT synchronousFaultInstruct() { + Map request = new HashMap<>(2); + // 获取站点列表 + R> stationsR = stationClient.list(new StationEntity()); + if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { + XxlJobLogger.log("获取站点列表失败!"); + return ReturnT.FAIL; + } + List updateStationList = stationsR.getData().stream().map(station -> { + UpdateStationVO stationVO = new UpdateStationVO(); + stationVO.setId(station.getCode()); + stationVO.setName(station.getName()); + return stationVO; + }).collect(Collectors.toList()); + request.put("stations", updateStationList); + interactiveService.updateFault(request); + return ReturnT.SUCCESS; + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index 9d3cefd..7317f54 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -9,6 +9,8 @@ public interface XxlJobHandlerConstant { /**获取问答结果**/ String GET_INTERACTIVE_RESULT = "getInteractiveResult"; + String SYNCHRONOUS_FAULT_INSTRUCT = "synchronousFaultInstruct"; + /**同步视频指令**/ String SYNCHRONOUS_VIDEO_INSTRUCT = "synchronousVideoInstruct"; From 232cd3523ad793243ca5dfc815aca08872890f88 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 11 May 2024 15:55:58 +0800 Subject: [PATCH 033/151] =?UTF-8?q?fix:=E8=BF=94=E5=9B=9E=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=93=8D=E5=BA=94=E5=AF=B9=E8=B1=A1extras=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0funcCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/service/impl/InteractiveServiceImpl.java | 10 ++++++---- .../interactive/service/impl/JumpRouteJoinStrategy.java | 1 + 2 files changed, 7 insertions(+), 4 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 d70bcd4..e596097 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 @@ -209,10 +209,12 @@ public class InteractiveServiceImpl implements IInteractiveService { 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("人员菜单鉴权失败!"); - }); + if(Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { + 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/service/impl/JumpRouteJoinStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java index e3b7f55..b0deed6 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 @@ -52,6 +52,7 @@ public class JumpRouteJoinStrategy { // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); JSONObject pathObject = JSONObject.parseObject(function.getPath()); + extraVO.setLabel(params.get("name")); // 云组态 if(picResource == 0) { String scada = pathObject.getString("scada"); From 8ea15ba11fd5efd8483310603e760ad21a2cf214 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 13 May 2024 08:37:39 +0800 Subject: [PATCH 034/151] =?UTF-8?q?add:choose=5Fvideo/choose=5Fcanvas?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/SelectionVO.java | 20 ------ .../interactive/constants/StationSelectionVO.java | 12 ---- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 2 - .../bigmodel/interactive/vo/ScadaSelectionVO.java | 16 +++++ .../hzims/bigmodel/interactive/vo/SelectionVO.java | 20 ++++++ .../interactive/vo/StationSelectionVO.java | 15 ++++ .../bigmodel/interactive/vo/VideoSelectionVO.java | 16 +++++ .../interactive/constants/FuncRouteEnum.java | 2 + .../service/impl/ExtraResolveStrategyService.java | 57 ++++++++++++++- .../service/impl/JumpRouteJoinStrategy.java | 11 +-- .../interactive/service/impl/ParamStrategy.java | 2 +- .../websocket/handler/InteractiveHandler.java | 81 ++++++++++++++++++++-- 12 files changed, 204 insertions(+), 50 deletions(-) delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java deleted file mode 100644 index a7a271f..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SelectionVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/09 16:30 - */ -@Data -public class SelectionVO implements Serializable { - - /**选项ID**/ - private String id; - - /**选项名称**/ - private String name; - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java deleted file mode 100644 index d67a829..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/StationSelectionVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.Data; - -/** - * @Author: huangxing - * @Date: 2024/05/09 16:32 - */ -@Data -public class StationSelectionVO extends SelectionVO { - -} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index cda702f..951bf42 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -1,10 +1,8 @@ package com.hnac.hzims.bigmodel.interactive.vo; -import com.hnac.hzims.bigmodel.interactive.constants.SelectionVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import net.sf.jsqlparser.statement.select.Select; import java.io.Serializable; import java.util.List; diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java new file mode 100644 index 0000000..b32cca2 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/11 16:21 + */ +@Data +@EqualsAndHashCode +public class ScadaSelectionVO extends SelectionVO implements Serializable { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java new file mode 100644 index 0000000..57899c9 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:30 + */ +@Data +public class SelectionVO implements Serializable { + + /**选项ID**/ + private String id; + + /**选项名称**/ + private String name; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java new file mode 100644 index 0000000..84209d9 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSelectionVO.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.hnac.hzims.bigmodel.interactive.vo.SelectionVO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/09 16:32 + */ +@Data +public class StationSelectionVO extends SelectionVO implements Serializable { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java new file mode 100644 index 0000000..0bcc529 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/VideoSelectionVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/11 16:20 + */ +@Data +@EqualsAndHashCode +public class VideoSelectionVO extends SelectionVO implements Serializable { + +} 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 724f97e..a78b0e9 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 @@ -16,6 +16,8 @@ public enum FuncRouteEnum { OPEN_VIDEO("open_video","打开视频监控"), DIAGNOSE("diagnose","智能诊断"), CHOOSE_STATION("choose_station","选择站点"), + CHOOSE_VIDEO("choose_video","选择视频"), + CHOOSE_CANVAS("choose_canvas","选择画面"), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 8419dee..9ab95cd 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -5,12 +5,15 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; +import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; +import com.hnac.hzims.bigmodel.interactive.vo.StationSelectionVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import lombok.AllArgsConstructor; -import lombok.Data; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; @@ -31,6 +34,8 @@ import java.util.stream.Collectors; public class ExtraResolveStrategyService { private final IStationClient stationClient; + private final IStationVideoTypeClient videoTypeClient; + private final JumpRouteJoinStrategy jumpRouteJoinStrategy; /** * 解析DFP返回extra @@ -39,7 +44,7 @@ public class ExtraResolveStrategyService { */ public ExtraVO resolve(String extraStr) { JSONObject extra = JSONObject.parseObject(extraStr); - String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse(""); + String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse("ttps"); if(StringUtil.isNotBlank(functionCode)) { FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); switch (funcRouteEnum) { @@ -47,6 +52,10 @@ public class ExtraResolveStrategyService { return this.resolveDiagnose(extra); case CHOOSE_STATION: return this.resolveChooseStation(extra); + case CHOOSE_VIDEO: + return this.resolveChooseVideo(extra); + case CHOOSE_CANVAS: + return this.resolveChooseScada(extra); default: break; } @@ -96,4 +105,46 @@ public class ExtraResolveStrategyService { result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); return result; } + + private ExtraVO resolveChooseVideo(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("videos")) { + List videoIds = JSONArray.parseArray(JSON.toJSONString(data.get("videos")), JSONObject.class); + List selections = videoIds.stream().map(video -> { + R videoR = videoTypeClient.getById(Long.valueOf(video.getString("id"))); + VideoSelectionVO selectionVO = new VideoSelectionVO(); + if (videoR.isSuccess() && Func.isNotEmpty(videoR.getData())) { + selectionVO.setId(video.getString("id")); + selectionVO.setName(videoR.getData().getName()); + } + return selectionVO; + }).collect(Collectors.toList()); + result.setFuncCode(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode()); + result.setSpecial(true); + result.setSelection(selections); + } + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + return result; + } + + private ExtraVO resolveChooseScada(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("canvases")) { + List canvases = JSONArray.parseArray(JSON.toJSONString(data.get("canvases")), JSONObject.class); + List selections = canvases.stream().map(canvas -> { + ScadaSelectionVO selectionVO = new ScadaSelectionVO(); + Map resolve = jumpRouteJoinStrategy.resolve(canvas.getString("id"), JumpRouteJoinStrategy.SCADA_PARAMS_SOLVE); + selectionVO.setId(canvas.getString("id")); + selectionVO.setName(resolve.get("name")); + return selectionVO; + }).collect(Collectors.toList()); + result.setFuncCode(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode()); + result.setSpecial(true); + result.setSelection(selections); + } + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + return result; + } } 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 b0deed6..4d51428 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 @@ -25,6 +25,8 @@ import java.util.stream.IntStream; @Component public class JumpRouteJoinStrategy { + public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; + /** * 解析大模型传参 * @param args 大模型传参 @@ -43,7 +45,7 @@ public class JumpRouteJoinStrategy { return null; } - private ExtraVO getScadaExtra(Map args,FunctionEntity function) { + public ExtraVO getScadaExtra(Map args,FunctionEntity function) { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); @@ -86,14 +88,13 @@ public class JumpRouteJoinStrategy { * @param args 大模型解析参数 * @return 实时画面路径拼接所需参数 */ - private Map scadaResolve(Map args) { + public Map scadaResolve(Map args) { 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); + return this.resolve(params,SCADA_PARAMS_SOLVE); } - private Map resolve(String paramsStr,String... keys) { + public Map resolve(String paramsStr,String... keys) { Map result = new HashMap<>(); List params = Func.toStrList("\\^", paramsStr); Assert.isTrue(params.size() == keys.length, () -> { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index 6e9cd62..76a22d5 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -46,7 +46,7 @@ public class ParamStrategy { return null; } - private ExtraVO getVideoExtra(Map args) { + public ExtraVO getVideoExtra(Map args) { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); String id = args.get("canvas_id"); 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 3a25314..700e44b 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 @@ -2,16 +2,19 @@ package com.hnac.hzims.bigmodel.websocket.handler; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; +import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; +import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; +import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; -import org.springframework.util.Assert; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -20,8 +23,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.function.Function; /** * @Author: huangxing @@ -80,7 +82,13 @@ public class InteractiveHandler extends TextWebSocketHandler { FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); switch (funcEnum) { case CHOOSE_STATION: - this.handleChooseStation(messageContext,sessionId); + this.handleDefaultChoose(messageContext,sessionId); + break; + case CHOOSE_VIDEO: + this.handleVideoChoose(messageContext,sessionId); + break; + case CHOOSE_CANVAS: + this.handleScadaChoose(messageContext,sessionId); break; default: break; @@ -88,7 +96,7 @@ public class InteractiveHandler extends TextWebSocketHandler { } } - private void handleChooseStation(JSONObject messageContext,String sessionId) { + private void handleDefaultChoose(JSONObject messageContext,String sessionId) { IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); String userId = messageContext.getString("userId"); String funcCode = messageContext.getString("funcCode"); @@ -101,4 +109,63 @@ public class InteractiveHandler extends TextWebSocketHandler { extra.put("data",data); interactiveService.specialAsk(sessionId,userId,extra); } + + private void handleVideoChoose(JSONObject messageContext,String sessionId) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + ParamStrategy strategy = SpringUtil.getBean(ParamStrategy.class); + VideoSelectionVO selection = messageContext.getObject("selection", VideoSelectionVO.class); + String videoId = selection.getId(); + Map param = new HashMap<>(1); + param.put("canvas_id",videoId); + ExtraVO videoExtras = strategy.getVideoExtra(param); + AnswerVO answerVO = new AnswerVO(); + answerVO.setSessionId(sessionId); + answerVO.setQuery(selection.getName()); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setAnswer("已成功打开"+selection.getName()+"视频"); + answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(sessionId,textMessage); + } + catch (Exception e) { + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("视频解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(sessionId,textMessage); + } + } + + private void handleScadaChoose(JSONObject messageContext,String sessionId) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + JumpRouteJoinStrategy strategy = SpringUtil.getBean(JumpRouteJoinStrategy.class); + ScadaSelectionVO selection = messageContext.getObject("selection", ScadaSelectionVO.class); + Map param = new HashMap<>(1); + param.put("canvas_id",selection.getId()); + IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); + FunctionEntity function = functionService.getFunctionByCode("open_scada"); + ExtraVO scadaExtra = strategy.getScadaExtra(param, function); + AnswerVO answerVO = new AnswerVO(); + answerVO.setSessionId(sessionId); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setQuery(selection.getName()); + answerVO.setAnswer("已成功打开"+selection.getName()+"实时画面"); + answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(sessionId,textMessage); + } + catch (Exception e) { + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("实时画面解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(sessionId,textMessage); + } + } } From e7df146953b53232f2861113e7ca03e3fc090ddb Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 13 May 2024 11:18:06 +0800 Subject: [PATCH 035/151] =?UTF-8?q?add:=E8=A7=86=E9=A2=91=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E8=B7=B3=E8=BD=AC=E5=AD=97=E6=AE=B5=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E4=B8=BAtrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index 76a22d5..e84f616 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -55,6 +55,7 @@ public class ParamStrategy { if(videoR.isSuccess()) { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + extraVO.setImmediatelyJump(true); extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); Map params = new HashMap<>(); params.put("name", video.getName()); From f7b8cfd53dec9a936ca132c65967f897539e1aed Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 13 May 2024 16:24:46 +0800 Subject: [PATCH 036/151] =?UTF-8?q?fix:=E5=AE=9E=E6=97=B6=E7=94=BB?= =?UTF-8?q?=E9=9D=A2label=E6=B7=BB=E5=8A=A0=E7=AB=99=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExtraResolveStrategyService.java | 5 ++++- .../interactive/service/impl/JumpRouteJoinStrategy.java | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 9ab95cd..3e5f6c6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -13,6 +13,8 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; @@ -44,8 +46,9 @@ public class ExtraResolveStrategyService { */ public ExtraVO resolve(String extraStr) { JSONObject extra = JSONObject.parseObject(extraStr); - String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse("ttps"); + String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse(""); if(StringUtil.isNotBlank(functionCode)) { + XxlJobLogger.log("函数编号为:" + functionCode); FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); switch (funcRouteEnum) { case DIAGNOSE: 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 4d51428..d24a4c0 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 @@ -6,16 +6,17 @@ import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.RequiredArgsConstructor; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Component; import org.springframework.util.Assert; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.IntStream; /** @@ -23,8 +24,11 @@ import java.util.stream.IntStream; * @Date: 2024/04/30 11:38 */ @Component +@RequiredArgsConstructor public class JumpRouteJoinStrategy { + private final IStationClient stationClient; + public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; /** @@ -54,7 +58,8 @@ public class JumpRouteJoinStrategy { // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); JSONObject pathObject = JSONObject.parseObject(function.getPath()); - extraVO.setLabel(params.get("name")); + R stationR = stationClient.getStationByCode(params.get("projectId")); + extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName) + "_" + params.get("name")); // 云组态 if(picResource == 0) { String scada = pathObject.getString("scada"); From 71d1e85dc2c224c9930a17f8812b3a375b0bfa89 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 13 May 2024 16:57:53 +0800 Subject: [PATCH 037/151] =?UTF-8?q?#=E7=94=A8=E6=88=B7=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=89=B4=E6=9D=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 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 e596097..f59aefb 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 @@ -204,11 +204,8 @@ public class InteractiveServiceImpl implements IInteractiveService { }); } // 菜单鉴权 - if(StringUtil.isNotBlank(funcCode)) { + if(StringUtil.isNotBlank(funcCode) && StringUtil.isNotBlank(userId)) { FunctionEntity function = functionService.getFunctionByCode(funcCode); - Assert.isTrue(Func.isNotEmpty(function) && StringUtil.isNotBlank(function.getRoute()),() -> { - throw new ServiceException("传入函数未获取到菜单,鉴权失败!"); - }); if(Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { From 995b318b1f75eea8d7780172e8d65112d9b0b3b4 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 14 May 2024 08:14:20 +0800 Subject: [PATCH 038/151] =?UTF-8?q?fix:=E5=AE=9E=E6=97=B6=E7=94=BB?= =?UTF-8?q?=E9=9D=A2label=E6=B7=BB=E5=8A=A0=E7=AB=99=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d24a4c0..2ad7ae3 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 @@ -59,7 +59,7 @@ public class JumpRouteJoinStrategy { Integer picResource = Integer.valueOf(params.get("picResource")); JSONObject pathObject = JSONObject.parseObject(function.getPath()); R stationR = stationClient.getStationByCode(params.get("projectId")); - extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName) + "_" + params.get("name")); + extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); // 云组态 if(picResource == 0) { String scada = pathObject.getString("scada"); From 99a4ad830e2108cf94f66f975d4b43dcc10720f4 Mon Sep 17 00:00:00 2001 From: RnhaiWang <393727820@qq.com> Date: Tue, 14 May 2024 10:18:57 +0800 Subject: [PATCH 039/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java index f8313af..558bf50 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java @@ -145,7 +145,7 @@ public class RobotServiceImpl extends BaseServiceImpl Result> deviceSoeDataResult = deviceDataClient.getDeviceSoeData(robot.getStationCode(), 1, robotCode, null, startTime, endTime, true, query.getCurrent(), query.getSize()); Assert.isTrue(deviceSoeDataResult.isSuccess(), () -> { - throw new ServiceException("获取机器人告警信息失败!"); + throw new ServiceException(deviceSoeDataResult.getMsg()); }); Map deviceSoeData = deviceSoeDataResult.getData(); IPage result = Condition.getPage(query); From 27e18383a6c57c4ef8ed2b455ee134e85f0cbe39 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 15:28:22 +0800 Subject: [PATCH 040/151] =?UTF-8?q?fix:open=5Fscada=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAopen=5Fcanvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java | 2 +- .../bigmodel/interactive/controller/InteractiveController.java | 4 ++-- .../hzims/bigmodel/interactive/service/IInteractiveService.java | 2 +- .../bigmodel/interactive/service/impl/InteractiveServiceImpl.java | 8 ++++---- .../bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 4 ++-- .../com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 5 ++--- .../hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java | 2 +- 7 files changed, 13 insertions(+), 14 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 a78b0e9..aca3fab 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 @@ -12,7 +12,7 @@ import java.util.Optional; */ @AllArgsConstructor public enum FuncRouteEnum { - OPEN_SCADA("open_scada","打开实时画面"), + OPEN_CANVAS("open_canvas","打开实时画面"), OPEN_VIDEO("open_video","打开视频监控"), DIAGNOSE("diagnose","智能诊断"), CHOOSE_STATION("choose_station","选择站点"), 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 7739800..90102a3 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 funcCode) { - return R.status(interactiveService.authentication(stationId,userId,funcCode)); + @RequestParam(required = false) @ApiParam("菜单ID") String func) { + return R.status(interactiveService.authentication(stationId,userId,func)); } @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 b85ad2f..40b06ea 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 @@ -30,7 +30,7 @@ public interface IInteractiveService { List getAnswerBySessionIds(String sessionIds); - Boolean authentication(String stationId, String userId, String funcCode); + Boolean authentication(String stationId, String userId, String func); Boolean removeSessionId(String sessionId); } 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 f59aefb..1c09556 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 @@ -194,7 +194,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override - public Boolean authentication(String stationId, String userId, String funcCode) { + public Boolean authentication(String stationId, String userId, String func) { // 站点鉴权 if(StringUtil.isNotBlank(stationId)) { List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) @@ -204,9 +204,9 @@ public class InteractiveServiceImpl implements IInteractiveService { }); } // 菜单鉴权 - if(StringUtil.isNotBlank(funcCode) && StringUtil.isNotBlank(userId)) { - FunctionEntity function = functionService.getFunctionByCode(funcCode); - if(Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { + if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { + FunctionEntity function = functionService.getFunctionByCode(func); + if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { throw new ServiceException("人员菜单鉴权失败!"); 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 2ad7ae3..6c320a3 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 @@ -40,7 +40,7 @@ public class JumpRouteJoinStrategy { FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); if(Func.isNotEmpty(routeEnum)) { switch(routeEnum) { - case OPEN_SCADA: + case OPEN_CANVAS: return this.getScadaExtra(args,function); default: break; @@ -53,7 +53,7 @@ public class JumpRouteJoinStrategy { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); - extraVO.setFuncCode(FuncRouteEnum.OPEN_SCADA.getFuncCode()); + extraVO.setFuncCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); 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 629d287..85affae 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 @@ -193,9 +193,8 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } - //@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) String params - @Scheduled(cron = "0/10 * * * * ?") - public ReturnT synchronousFaultInstruct() { + @XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) + public ReturnT synchronousFaultInstruct(String params) { Map request = new HashMap<>(2); // 获取站点列表 R> stationsR = stationClient.list(new StationEntity()); 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 700e44b..bc475f7 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 @@ -147,7 +147,7 @@ public class InteractiveHandler extends TextWebSocketHandler { Map param = new HashMap<>(1); param.put("canvas_id",selection.getId()); IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); - FunctionEntity function = functionService.getFunctionByCode("open_scada"); + FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); ExtraVO scadaExtra = strategy.getScadaExtra(param, function); AnswerVO answerVO = new AnswerVO(); answerVO.setSessionId(sessionId); From 4f85176c37666eeb24b1d417d423486769658b93 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 17:01:38 +0800 Subject: [PATCH 041/151] =?UTF-8?q?fix:open=5Fscada=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAopen=5Fcanvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FuncRouteEnum.java | 2 +- .../service/impl/ExtraResolveStrategyService.java | 24 ++++++++++++---------- .../service/impl/InteractiveServiceImpl.java | 3 +++ 3 files changed, 17 insertions(+), 12 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 aca3fab..c4fc85e 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 @@ -26,7 +26,7 @@ public enum FuncRouteEnum { public static FuncRouteEnum getEnumByFuncCode(String funcCode) { Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst(); - return FuncRoute.get(); + return FuncRoute.orElse(null); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 3e5f6c6..a9c590b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -50,17 +50,19 @@ public class ExtraResolveStrategyService { if(StringUtil.isNotBlank(functionCode)) { XxlJobLogger.log("函数编号为:" + functionCode); FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); - switch (funcRouteEnum) { - case DIAGNOSE: - return this.resolveDiagnose(extra); - case CHOOSE_STATION: - return this.resolveChooseStation(extra); - case CHOOSE_VIDEO: - return this.resolveChooseVideo(extra); - case CHOOSE_CANVAS: - return this.resolveChooseScada(extra); - default: - break; + if(Func.isNotEmpty(funcRouteEnum)) { + switch (funcRouteEnum) { + case DIAGNOSE: + return this.resolveDiagnose(extra); + case CHOOSE_STATION: + return this.resolveChooseStation(extra); + case CHOOSE_VIDEO: + return this.resolveChooseVideo(extra); + case CHOOSE_CANVAS: + return this.resolveChooseScada(extra); + default: + break; + } } } return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); 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 1c09556..4e835a0 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 @@ -73,6 +73,9 @@ public class InteractiveServiceImpl implements IInteractiveService { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); + if(Func.isEmpty(typeEnum)) { + throw new ServiceException("函数解析失败!"); + } switch (typeEnum) { // 页面跳转 case JUMP: From 75384cd9504b5a0c3be385fb8f070fce85ce9094 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 15 May 2024 17:32:29 +0800 Subject: [PATCH 042/151] =?UTF-8?q?fix:=E5=AE=9E=E6=97=B6=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E7=94=BB=E9=9D=A2=E7=B1=BB=E5=9E=8B=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 3 +++ 1 file changed, 3 insertions(+) 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 6c320a3..ddb6f69 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 @@ -60,6 +60,9 @@ public class JumpRouteJoinStrategy { JSONObject pathObject = JSONObject.parseObject(function.getPath()); R stationR = stationClient.getStationByCode(params.get("projectId")); extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); + Map extraParams = new HashMap<>(1); + extraParams.put("picResource",picResource); + extraVO.setParams(extraParams); // 云组态 if(picResource == 0) { String scada = pathObject.getString("scada"); From bdb19c110e3be05e59bfca4f4326fcd8bc2c78c3 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 16 May 2024 15:36:17 +0800 Subject: [PATCH 043/151] =?UTF-8?q?fix:=E9=80=89=E6=8B=A9=E6=95=85?= =?UTF-8?q?=E9=9A=9C=E5=87=BD=E6=95=B0=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/vo/FaultSelectionVO.java | 16 ++++++++++++++++ .../interactive/constants/FuncRouteEnum.java | 1 + .../service/impl/ExtraResolveStrategyService.java | 20 ++++++++++++++++---- .../websocket/handler/InteractiveHandler.java | 17 +++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java new file mode 100644 index 0000000..00aa21e --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/16 15:10 + */ +@Data +@EqualsAndHashCode +public class FaultSelectionVO extends SelectionVO implements Serializable { + +} 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 c4fc85e..3dd1caf 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 @@ -18,6 +18,7 @@ public enum FuncRouteEnum { CHOOSE_STATION("choose_station","选择站点"), CHOOSE_VIDEO("choose_video","选择视频"), CHOOSE_CANVAS("choose_canvas","选择画面"), + CHOOSE_FAULT("choose_fault","选择故障"), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index a9c590b..c1895b9 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; -import com.hnac.hzims.bigmodel.interactive.vo.StationSelectionVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; +import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -60,6 +57,8 @@ public class ExtraResolveStrategyService { return this.resolveChooseVideo(extra); case CHOOSE_CANVAS: return this.resolveChooseScada(extra); + case CHOOSE_FAULT: + return this.resolveChooseFault(extra); default: break; } @@ -68,6 +67,19 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveChooseFault(Map extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("faults")) { + List faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); + result.setSelection(faults); + } + result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); + result.setSpecial(true); + result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); + return result; + } + private ExtraVO resolveDiagnose(Map extra) { ExtraVO result = new ExtraVO(); JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); 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 bc475f7..96dfc4e 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 @@ -90,6 +90,9 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_CANVAS: this.handleScadaChoose(messageContext,sessionId); break; + case CHOOSE_FAULT: + this.handleFaultChoose(messageContext,sessionId); + break; default: break; } @@ -168,4 +171,18 @@ public class InteractiveHandler extends TextWebSocketHandler { wsService.sendMessage(sessionId,textMessage); } } + + private void handleFaultChoose(JSONObject messageContext,String sessionId) { + IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + String userId = messageContext.getString("userId"); + String funcCode = messageContext.getString("funcCode"); + FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); + JSONObject data = new JSONObject(); + data.put("id",selectionVO.getId()); + data.put("name",selectionVO.getName()); + Map extra = new HashMap<>(2); + extra.put("func",funcCode); + extra.put("data",data); + interactiveService.specialAsk(sessionId,userId,extra); + } } From 5fb2f2f43af4cd5389537a2565dd555811336f9b Mon Sep 17 00:00:00 2001 From: Jone <515616805@qq.com> Date: Fri, 17 May 2024 09:57:29 +0800 Subject: [PATCH 044/151] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpackage=E5=8C=85?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java index a800d2b..4345391 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/web/MsgWsRecordHistoryController.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.message.controller; +package com.hnac.hzims.message.web; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; * @author xiashandong * @created 2021-06-28 16:45 **/ +@Deprecated @RestController @AllArgsConstructor @RequestMapping("/msg/ws/record/history") From da5516f038566fa0c54ab20e2119a0322acc1818 Mon Sep 17 00:00:00 2001 From: RnhaiWang <393727820@qq.com> Date: Fri, 17 May 2024 13:59:21 +0800 Subject: [PATCH 045/151] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java | 1 + .../main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java index 558bf50..13d8cb0 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java @@ -129,6 +129,7 @@ public class RobotServiceImpl extends BaseServiceImpl Optional attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst(); data.setModelClassifyId(attrOptional.get().getModelClassifyId()); data.setModelClassifyName(attrOptional.get().getModelClassifyName()); + data.setUnits(attrOptional.get().getUnits()); return data; })).collect(Collectors.toList()); return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName)); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java index f3371a7..00e3eda 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java @@ -49,4 +49,7 @@ public class RobotRealDataVO implements Serializable { @ApiModelProperty("启停状态") private Integer state; + + @ApiModelProperty("单位") + private String units; } From 0f8340d0521867b7e972e1a87185c41ea217c2b1 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 17 May 2024 14:18:09 +0800 Subject: [PATCH 046/151] =?UTF-8?q?#=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F&=E7=94=9F=E6=80=81=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/common/enums/ExceptionEnum.java | 102 ++++++ .../digital-twin-display-api.iml | 238 -------------- hzims-service-api/pom.xml | 2 +- hzims-service-api/spare-api/pom.xml | 16 - hzims-service-api/spare-api/spare-api.iml | 226 ------------- .../java/com/hnac/hzims/spare/entity/Notice.java | 64 ---- .../com/hnac/hzims/spare/feign/INoticeClient.java | 50 --- .../java/com/hnac/hzims/spare/vo/NoticeVO.java | 20 -- .../video-image-api/video-image-api.iml | 239 -------------- .../water-quality-api/water-quality-api.iml | 239 -------------- .../water-rain-api/water-rain-api.iml | 239 -------------- .../bigmodel/schedule/InteractiveSchedule.java | 6 +- hzims-service/hzims-simulate/pom.xml | 129 ++++++++ .../hnac/hzims/simulate/SimulateApplication.java | 28 ++ .../simulate/constants/WriteRealDataConstant.java | 43 +++ .../hzims/simulate/controller/GageController.java | 31 ++ .../controller/SimulationDataController.java | 195 +++++++++++ .../com/hnac/hzims/simulate/entity/DataItem.java | 20 ++ .../com/hnac/hzims/simulate/entity/DataModel.java | 46 +++ .../com/hnac/hzims/simulate/entity/Device.java | 66 ++++ .../com/hnac/hzims/simulate/entity/DeviceData.java | 22 ++ .../hnac/hzims/simulate/entity/DeviceDataV4.java | 19 ++ .../hzims/simulate/entity/DeviceFacConfig.java | 38 +++ .../hnac/hzims/simulate/entity/DeviceField.java | 42 +++ .../hnac/hzims/simulate/entity/DeviceFieldGap.java | 30 ++ .../hnac/hzims/simulate/entity/DeviceRainGap.java | 33 ++ .../java/com/hnac/hzims/simulate/entity/Kvtq.java | 18 ++ .../com/hnac/hzims/simulate/entity/KvtqV4.java | 18 ++ .../simulate/mapper/DeviceFacConfigMapper.java | 19 ++ .../simulate/mapper/DeviceFacConfigMapper.xml | 13 + .../simulate/mapper/DeviceFieldGapMapper.java | 16 + .../hzims/simulate/mapper/DeviceFieldGapMapper.xml | 18 ++ .../hzims/simulate/mapper/DeviceFieldMapper.java | 19 ++ .../hzims/simulate/mapper/DeviceFieldMapper.xml | 34 ++ .../hnac/hzims/simulate/mapper/DeviceMapper.java | 15 + .../hnac/hzims/simulate/mapper/DeviceMapper.xml | 15 + .../hzims/simulate/mapper/DeviceRainGapMapper.java | 17 + .../hzims/simulate/mapper/DeviceRainGapMapper.xml | 9 + .../simulate/scheduled/WriteRealDataTask.java | 53 +++ .../simulate/service/DeviceFieldGapService.java | 11 + .../hzims/simulate/service/DeviceFieldService.java | 24 ++ .../hnac/hzims/simulate/service/DeviceService.java | 21 ++ .../hzims/simulate/service/SimulationService.java | 280 ++++++++++++++++ .../simulate/service/WriteRealDataService.java | 13 + .../service/impl/WriteRealDataServiceImpl.java | 304 ++++++++++++++++++ .../hnac/hzims/simulate/util/DataConstants.java | 357 +++++++++++++++++++++ .../hnac/hzims/simulate/util/ParseFacUtils.java | 105 ++++++ .../hzims/simulate/util/RealIdConvertUtils.java | 52 +++ .../hnac/hzims/simulate/util/TopicConstant.java | 18 ++ .../src/main/resources/application-dev.yml | 13 + .../src/main/resources/application-prod.yml | 6 + .../src/main/resources/application.yml | 15 + .../station/controller/HikVideoController.java | 4 +- .../controller/StationVideoTypeController.java | 4 +- .../station/service/IHikVideoService.java | 2 +- .../station/service/IStationVideoTypeService.java | 2 +- .../station/service/impl/HikVideoServiceImpl.java | 23 +- .../service/impl/StationVideoTypeServiceImpl.java | 4 +- hzims-service/pom.xml | 2 + hzims-service/spare/Dockerfile | 24 -- hzims-service/spare/pom.xml | 96 ------ .../com/hnac/hzims/spare/SpareApplication.java | 40 --- .../hnac/hzims/spare/config/DemoConfiguration.java | 37 --- .../hzims/spare/controller/DemoController.java | 58 ---- .../hzims/spare/controller/DynamicController.java | 67 ---- .../controller/HzimsSpChangeDetailController.java | 87 ----- .../controller/HzimsSpChangeRecController.java | 111 ------- .../spare/controller/HzimsSpFileController.java | 97 ------ .../controller/HzimsSpProviderController.java | 125 -------- .../controller/HzimsSpRelevanceFileController.java | 97 ------ .../spare/controller/HzimsSpTypeController.java | 151 --------- .../controller/HzimsSpWareRelatedController.java | 87 ----- .../controller/HzimsSpWarehouseController.java | 120 ------- .../controller/HzimsSparePartsController.java | 123 ------- .../hzims/spare/controller/NoticeController.java | 116 ------- .../hzims/spare/controller/UploadController.java | 41 --- .../hzims/spare/dto/HzimsSpChangeDetailDTO.java | 18 -- .../hnac/hzims/spare/dto/HzimsSpChangeRecDTO.java | 31 -- .../com/hnac/hzims/spare/dto/HzimsSpFileDTO.java | 18 -- .../hnac/hzims/spare/dto/HzimsSpProviderDTO.java | 18 -- .../hzims/spare/dto/HzimsSpRelevanceFileDTO.java | 18 -- .../com/hnac/hzims/spare/dto/HzimsSpTypeDTO.java | 62 ---- .../hzims/spare/dto/HzimsSpWareRelatedDTO.java | 18 -- .../hnac/hzims/spare/dto/HzimsSpWarehouseDTO.java | 18 -- .../hnac/hzims/spare/dto/HzimsSpareCountDTO.java | 61 ---- .../hnac/hzims/spare/dto/HzimsSparePartsDTO.java | 18 -- .../spare/entity/HzimsSpChangeDetailEntity.java | 89 ----- .../hzims/spare/entity/HzimsSpChangeRecEntity.java | 62 ---- .../hnac/hzims/spare/entity/HzimsSpFileEntity.java | 57 ---- .../hzims/spare/entity/HzimsSpProviderEntity.java | 77 ----- .../spare/entity/HzimsSpRelevanceFileEntity.java | 42 --- .../hnac/hzims/spare/entity/HzimsSpTypeEntity.java | 55 ---- .../spare/entity/HzimsSpWareRelatedEntity.java | 54 ---- .../hzims/spare/entity/HzimsSpWarehouseEntity.java | 57 ---- .../hzims/spare/entity/HzimsSparePartsEntity.java | 82 ----- .../hzims/spare/enumeration/ChangeStatusEnum.java | 70 ---- .../com/hnac/hzims/spare/feign/NoticeClient.java | 47 --- .../spare/mapper/HzimsSpChangeDetailMapper.java | 26 -- .../spare/mapper/HzimsSpChangeDetailMapper.xml | 42 --- .../hzims/spare/mapper/HzimsSpChangeRecMapper.java | 20 -- .../hzims/spare/mapper/HzimsSpChangeRecMapper.xml | 30 -- .../hnac/hzims/spare/mapper/HzimsSpFileMapper.java | 20 -- .../hnac/hzims/spare/mapper/HzimsSpFileMapper.xml | 22 -- .../hzims/spare/mapper/HzimsSpProviderMapper.java | 20 -- .../hzims/spare/mapper/HzimsSpProviderMapper.xml | 28 -- .../spare/mapper/HzimsSpRelevanceFileMapper.java | 21 -- .../spare/mapper/HzimsSpRelevanceFileMapper.xml | 22 -- .../hnac/hzims/spare/mapper/HzimsSpTypeMapper.java | 32 -- .../hnac/hzims/spare/mapper/HzimsSpTypeMapper.xml | 38 --- .../spare/mapper/HzimsSpWareRelatedMapper.java | 39 --- .../spare/mapper/HzimsSpWareRelatedMapper.xml | 59 ---- .../hzims/spare/mapper/HzimsSpWarehouseMapper.java | 20 -- .../hzims/spare/mapper/HzimsSpWarehouseMapper.xml | 28 -- .../hzims/spare/mapper/HzimsSparePartsMapper.java | 37 --- .../hzims/spare/mapper/HzimsSparePartsMapper.xml | 84 ----- .../com/hnac/hzims/spare/mapper/NoticeMapper.java | 48 --- .../com/hnac/hzims/spare/mapper/NoticeMapper.xml | 39 --- .../com/hnac/hzims/spare/props/DemoProperties.java | 18 -- .../hnac/hzims/spare/service/IDynamicService.java | 45 --- .../spare/service/IHzimsSpChangeDetailService.java | 22 -- .../spare/service/IHzimsSpChangeRecService.java | 42 --- .../hzims/spare/service/IHzimsSpFileService.java | 13 - .../spare/service/IHzimsSpProviderService.java | 20 -- .../service/IHzimsSpRelevanceFileService.java | 13 - .../hzims/spare/service/IHzimsSpTypeService.java | 41 --- .../spare/service/IHzimsSpWareRelatedService.java | 35 -- .../spare/service/IHzimsSpWarehouseService.java | 20 -- .../spare/service/IHzimsSparePartsService.java | 50 --- .../hnac/hzims/spare/service/INoticeService.java | 38 --- .../spare/service/impl/DynamicServiceImpl.java | 30 -- .../impl/HzimsSpChangeDetailServiceImpl.java | 35 -- .../service/impl/HzimsSpChangeRecServiceImpl.java | 216 ------------- .../spare/service/impl/HzimsSpFileServiceImpl.java | 17 - .../service/impl/HzimsSpProviderServiceImpl.java | 22 -- .../impl/HzimsSpRelevanceFileServiceImpl.java | 17 - .../spare/service/impl/HzimsSpTypeServiceImpl.java | 48 --- .../impl/HzimsSpWareRelatedServiceImpl.java | 47 --- .../service/impl/HzimsSpWarehouseServiceImpl.java | 22 -- .../service/impl/HzimsSparePartsServiceImpl.java | 100 ------ .../spare/service/impl/NoticeServiceImpl.java | 39 --- .../hzims/spare/utils/CodeDateRandomUtils.java | 68 ---- .../com/hnac/hzims/spare/utils/TreeObject.java | 29 -- .../java/com/hnac/hzims/spare/utils/TreeUtil.java | 200 ------------ .../java/com/hnac/hzims/spare/utils/UserUtils.java | 25 -- .../hnac/hzims/spare/vo/HzimsSpChangeDetailVO.java | 18 -- .../hnac/hzims/spare/vo/HzimsSpChangeRecVO.java | 18 -- .../com/hnac/hzims/spare/vo/HzimsSpFileVO.java | 18 -- .../com/hnac/hzims/spare/vo/HzimsSpProviderVO.java | 18 -- .../hzims/spare/vo/HzimsSpRelevanceFileVO.java | 18 -- .../com/hnac/hzims/spare/vo/HzimsSpTypeVO.java | 18 -- .../hnac/hzims/spare/vo/HzimsSpWareRelatedVO.java | 18 -- .../hnac/hzims/spare/vo/HzimsSpWarehouseVO.java | 18 -- .../com/hnac/hzims/spare/vo/HzimsSparePartsVO.java | 18 -- .../spare/wrapper/HzimsSpChangeDetailWrapper.java | 31 -- .../spare/wrapper/HzimsSpChangeRecWrapper.java | 31 -- .../hzims/spare/wrapper/HzimsSpFileWrapper.java | 31 -- .../spare/wrapper/HzimsSpProviderWrapper.java | 31 -- .../spare/wrapper/HzimsSpRelevanceFileWrapper.java | 31 -- .../hzims/spare/wrapper/HzimsSpTypeWrapper.java | 31 -- .../spare/wrapper/HzimsSpWareRelatedWrapper.java | 31 -- .../spare/wrapper/HzimsSpWarehouseWrapper.java | 31 -- .../spare/wrapper/HzimsSparePartsWrapper.java | 31 -- .../spare/src/test/java/BladeDemoTest.java | 31 -- .../java/launcher/DemoTestLauncherServiceImpl.java | 48 --- 164 files changed, 2362 insertions(+), 6261 deletions(-) create mode 100644 hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java delete mode 100644 hzims-service-api/digital-twin-display-api/digital-twin-display-api.iml delete mode 100644 hzims-service-api/spare-api/pom.xml delete mode 100644 hzims-service-api/spare-api/spare-api.iml delete mode 100644 hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/entity/Notice.java delete mode 100644 hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/feign/INoticeClient.java delete mode 100644 hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/vo/NoticeVO.java delete mode 100644 hzims-service-api/video-image-api/video-image-api.iml delete mode 100644 hzims-service-api/water-quality-api/water-quality-api.iml delete mode 100644 hzims-service-api/water-rain-api/water-rain-api.iml create mode 100644 hzims-service/hzims-simulate/pom.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java create mode 100644 hzims-service/hzims-simulate/src/main/resources/application-dev.yml create mode 100644 hzims-service/hzims-simulate/src/main/resources/application-prod.yml create mode 100644 hzims-service/hzims-simulate/src/main/resources/application.yml delete mode 100644 hzims-service/spare/Dockerfile delete mode 100644 hzims-service/spare/pom.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/SpareApplication.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/config/DemoConfiguration.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DemoController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DynamicController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeDetailController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeRecController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpFileController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpProviderController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpRelevanceFileController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpTypeController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWareRelatedController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWarehouseController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSparePartsController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/NoticeController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/UploadController.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeDetailDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeRecDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpFileDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpProviderDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpRelevanceFileDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpTypeDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWareRelatedDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWarehouseDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpareCountDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSparePartsDTO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeDetailEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeRecEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpFileEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpProviderEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpRelevanceFileEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpTypeEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWareRelatedEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWarehouseEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSparePartsEntity.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/enumeration/ChangeStatusEnum.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/feign/NoticeClient.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.xml delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/props/DemoProperties.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IDynamicService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeDetailService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeRecService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpFileService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpProviderService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpRelevanceFileService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpTypeService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWareRelatedService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWarehouseService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSparePartsService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/INoticeService.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/DynamicServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeDetailServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeRecServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpFileServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpProviderServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpRelevanceFileServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpTypeServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWareRelatedServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWarehouseServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSparePartsServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/NoticeServiceImpl.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/CodeDateRandomUtils.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeObject.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeUtil.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/UserUtils.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeDetailVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeRecVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpFileVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpProviderVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpRelevanceFileVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpTypeVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWareRelatedVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWarehouseVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSparePartsVO.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeDetailWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeRecWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpFileWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpProviderWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpRelevanceFileWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpTypeWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWareRelatedWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWarehouseWrapper.java delete mode 100644 hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSparePartsWrapper.java delete mode 100644 hzims-service/spare/src/test/java/BladeDemoTest.java delete mode 100644 hzims-service/spare/src/test/java/launcher/DemoTestLauncherServiceImpl.java diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java new file mode 100644 index 0000000..9bb7532 --- /dev/null +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java @@ -0,0 +1,102 @@ +package com.hnac.hzims.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springblade.core.tool.api.IResultCode; + +import javax.servlet.http.HttpServletResponse; + +/** + * 异常码枚举类 + */ +@Getter +@AllArgsConstructor +public enum ExceptionEnum implements IResultCode { + + /** + * 操作成功 + */ + SUCCESS(HttpServletResponse.SC_OK, "操作成功"), + + /** + * 业务异常 + */ + FAILURE(HttpServletResponse.SC_BAD_REQUEST, "业务异常"), + + /** + * 请求未授权 + */ + UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "请求未授权"), + + /** + * 客户端请求未授权 + */ + CLIENT_UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "客户端请求未授权"), + + /** + * 404 没找到请求 + */ + NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "404 没找到请求"), + + /** + * 消息不能读取 + */ + MSG_NOT_READABLE(HttpServletResponse.SC_BAD_REQUEST, "消息不能读取"), + + /** + * 不支持当前请求方法 + */ + METHOD_NOT_SUPPORTED(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "不支持当前请求方法"), + + /** + * 不支持当前媒体类型 + */ + MEDIA_TYPE_NOT_SUPPORTED(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"), + + /** + * 请求被拒绝 + */ + REQ_REJECT(HttpServletResponse.SC_FORBIDDEN, "请求被拒绝"), + + /** + * 服务器异常 + */ + INTERNAL_SERVER_ERROR(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器异常"), + + /** + * 缺少必要的请求参数 + */ + PARAM_MISS(HttpServletResponse.SC_BAD_REQUEST, "缺少必要的请求参数"), + + /** + * 请求参数类型错误 + */ + PARAM_TYPE_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数类型错误"), + + /** + * 请求参数绑定错误 + */ + PARAM_BIND_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数绑定错误"), + + /** + * 参数校验失败 + */ + PARAM_VALID_ERROR(HttpServletResponse.SC_BAD_REQUEST, "参数校验失败"), + + + /** + * 模拟数据失败 + */ + SIMULATE_ERROR(400, "模拟数据失败"), + + ; + + /** + * code编码 + */ + final int code; + /** + * 中文信息描述 + */ + final String message; +} \ No newline at end of file diff --git a/hzims-service-api/digital-twin-display-api/digital-twin-display-api.iml b/hzims-service-api/digital-twin-display-api/digital-twin-display-api.iml deleted file mode 100644 index 277c4cb..0000000 --- a/hzims-service-api/digital-twin-display-api/digital-twin-display-api.iml +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hzims-service-api/pom.xml b/hzims-service-api/pom.xml index 9974fff..59661cf 100644 --- a/hzims-service-api/pom.xml +++ b/hzims-service-api/pom.xml @@ -16,7 +16,6 @@ assets-api - topvision-api equipment-api basic-api @@ -30,6 +29,7 @@ middle-api alarm-api big-model-api + suichang-api diff --git a/hzims-service-api/spare-api/pom.xml b/hzims-service-api/spare-api/pom.xml deleted file mode 100644 index b45831f..0000000 --- a/hzims-service-api/spare-api/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - hzims-service-api - com.hnac.hzims - 4.0.0-SNAPSHOT - - 4.0.0 - - spare-api - ${project.artifactId} - jar - - diff --git a/hzims-service-api/spare-api/spare-api.iml b/hzims-service-api/spare-api/spare-api.iml deleted file mode 100644 index 660192e..0000000 --- a/hzims-service-api/spare-api/spare-api.iml +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/entity/Notice.java b/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/entity/Notice.java deleted file mode 100644 index 0c328ed..0000000 --- a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/entity/Notice.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springblade.core.mp.base.BaseEntity; - -import java.util.Date; - -/** - * 实体类 - * - * @author Chill - */ -@Data -@TableName("blade_notice") -@EqualsAndHashCode(callSuper = true) -public class Notice extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 标题 - */ - @ApiModelProperty(value = "标题") - private String title; - - /** - * 通知类型 - */ - @ApiModelProperty(value = "通知类型") - private Integer category; - - /** - * 发布日期 - */ - @ApiModelProperty(value = "发布日期") - private Date releaseTime; - - /** - * 内容 - */ - @ApiModelProperty(value = "内容") - private String content; - - -} diff --git a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/feign/INoticeClient.java b/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/feign/INoticeClient.java deleted file mode 100644 index ff3206f..0000000 --- a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/feign/INoticeClient.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.feign; - -import org.springblade.core.launch.constant.AppConstant; -import org.springblade.core.tool.api.R; -import com.hnac.hzims.spare.entity.Notice; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.List; - -/** - * Notice Feign接口类 - * - * @author Chill - */ -@FeignClient( - value = AppConstant.APPLICATION_DESK_NAME -) -public interface INoticeClient { - - String API_PREFIX = "/client"; - String TOP = API_PREFIX + "/top"; - - /** - * 获取notice列表 - * - * @param number - * @return - */ - @GetMapping(TOP) - R> top(@RequestParam("number") Integer number); - -} diff --git a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/vo/NoticeVO.java b/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/vo/NoticeVO.java deleted file mode 100644 index e367a45..0000000 --- a/hzims-service-api/spare-api/src/main/java/com/hnac/hzims/spare/vo/NoticeVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.Notice; - -/** - * 通知公告视图类 - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class NoticeVO extends Notice { - - @ApiModelProperty(value = "通知类型名") - private String categoryName; - -} diff --git a/hzims-service-api/video-image-api/video-image-api.iml b/hzims-service-api/video-image-api/video-image-api.iml deleted file mode 100644 index 3e0824c..0000000 --- a/hzims-service-api/video-image-api/video-image-api.iml +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hzims-service-api/water-quality-api/water-quality-api.iml b/hzims-service-api/water-quality-api/water-quality-api.iml deleted file mode 100644 index 3e0824c..0000000 --- a/hzims-service-api/water-quality-api/water-quality-api.iml +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hzims-service-api/water-rain-api/water-rain-api.iml b/hzims-service-api/water-rain-api/water-rain-api.iml deleted file mode 100644 index 3e0824c..0000000 --- a/hzims-service-api/water-rain-api/water-rain-api.iml +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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 629d287..df732d1 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 @@ -193,9 +193,9 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } - //@XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) String params - @Scheduled(cron = "0/10 * * * * ?") - public ReturnT synchronousFaultInstruct() { + @XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) + //@Scheduled(cron = "0/10 * * * * ?") + public ReturnT synchronousFaultInstruct(String params) { Map request = new HashMap<>(2); // 获取站点列表 R> stationsR = stationClient.list(new StationEntity()); diff --git a/hzims-service/hzims-simulate/pom.xml b/hzims-service/hzims-simulate/pom.xml new file mode 100644 index 0000000..72cbbb0 --- /dev/null +++ b/hzims-service/hzims-simulate/pom.xml @@ -0,0 +1,129 @@ + + + + com.hnac.hzims + hzims-service + 4.0.0-SNAPSHOT + + + 4.0.0 + hzims-simulate + jar + + + 8 + 8 + UTF-8 + + + + + + com.xuxueli + xxl-job-core + + + com.google.guava + failureaccess + 1.0.1 + + + org.springblade + blade-common + + + org.springblade + blade-core-boot + + + org.springblade + blade-core-cloud + + + + + org.springblade + blade-starter-http + + + org.springblade + blade-core-cloud + compile + + + + org.springblade + blade-starter-datascope + compile + + + org.projectlombok + lombok + + + + com.hnac.hzims + equipment-api + 4.0.0-SNAPSHOT + + + + com.hnac.hzims + weather-api + 4.0.0-SNAPSHOT + + + + com.hzinfo.framework + hnac-framework-mqtt-starters + + + + dom4j + dom4j + 1.6.1 + compile + + + org.springblade + blade-core-cloud + 5.1.1.RELEASE.fix.1 + compile + + + + + + + ${project.name}-${project.version} + + + src/main/java + + **/*.xml + + false + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.6.6 + + + + repackage + + + exec + + + + + + + + \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java new file mode 100644 index 0000000..59981d0 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.simulate; + +import org.mybatis.spring.annotation.MapperScan; +import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.launch.BladeApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.SpringCloudApplication; + + +/** + * @author admin + */ +@EnableBladeFeign +@SpringCloudApplication +@MapperScan(basePackages={"com.hnac.hzims.**.mapper"}) +//@ComponentScan(basePackages = {"com.hnac.hzinfo.simulate"}) +public class SimulateApplication extends SpringBootServletInitializer { + static String APPLICATION_NAME="hzims-simulate"; + public static void main(String[] args) { + BladeApplication.run(APPLICATION_NAME, SimulateApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return BladeApplication.createSpringApplicationBuilder(builder, APPLICATION_NAME, SimulateApplication.class); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java new file mode 100644 index 0000000..bd48066 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.simulate.constants; + +/** + * @author ysj + * @describe 实时数据写入常量 + */ +public interface WriteRealDataConstant { + + String REAL_DATA_V3 = "3"; + + String REAL_DATA_V4 = "4"; + + String GATE_FLOW = "过闸流量(m³/s)"; + + String OPENING_DEGREE = "开度(m)"; + + String GATE_STATUS = "闸门状态"; + + String WRITE_REAL_GATE_DATA = "writeRealGateData"; + + String WRITE_REAL_RAIN_DATA = "writeRealRainData"; + + Long OPEN = 0L; + + Long CLOSE = 1L; + + String WRITE_GATE = "1"; + + String WRITE_RAIN = "2"; + + // 降雨站属性标识 + String ATTR_RAIN = "attr_rain"; + String ATTR_WIND360 = "wind360"; + String ATTR_WIND_SCALE = "wind_scale"; + String ATTR_WIND_SPEED = "wind_speed "; + String ATTR_HUMIDITY = "humidity"; + String ATTR_PRESSURE = "pressure"; + String ATTR_VIS = "vis"; + String ATTR_CLOUD = "cloud"; + String ATTR_DEW = "dew"; + String ATTR_FEELS_LIKE = "feels_like"; + String ATTR_TEMP = "temp"; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java new file mode 100644 index 0000000..08ec0a8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.simulate.controller; + +import com.hnac.hzims.simulate.service.WriteRealDataService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/gate") +@Api(value = "闸门开关机模拟服务", tags = "闸门开关机模拟服务") +public class GageController { + + private final WriteRealDataService writeRealDataService; + + @GetMapping("/isOpen") + @ApiOperation(value = "枢纽天气情况") + public R weather(@RequestParam("deviceCode") String deviceCode, + @RequestParam("isOpen") Long isOpen){ + return R.data(writeRealDataService.isOpen(deviceCode,isOpen)); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java new file mode 100644 index 0000000..8d6d85c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java @@ -0,0 +1,195 @@ +package com.hnac.hzims.simulate.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.google.common.collect.Maps; +import com.hnac.hzims.common.enums.ExceptionEnum; +import com.hnac.hzims.simulate.entity.DataModel; +import com.hnac.hzims.simulate.entity.Device; +import com.hnac.hzims.simulate.entity.DeviceField; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import com.hnac.hzims.simulate.service.DeviceFieldGapService; +import com.hnac.hzims.simulate.service.DeviceFieldService; +import com.hnac.hzims.simulate.service.SimulationService; +import com.hnac.hzims.simulate.util.ParseFacUtils; +import com.hnac.hzims.simulate.util.TopicConstant; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/simulationData") +@Api(value = "数据模拟服务", tags = "数据模拟服务") +@Slf4j +public class SimulationDataController { + + @Autowired + private SimulationService simulationService; + + @Autowired + private DeviceFieldService deviceFieldService; + + @Autowired + private DeviceFieldGapService deviceFieldGapService; + + @Autowired + private IMqttSender mqttSender; + + @Value("fac.path") + private String facPath; + + public static Map cacheMap = Maps.newHashMap(); + + @ApiOperation(value = "解析v3.0场信息文件", notes = "解析场信息文件") + @GetMapping("/readFac") + public R readFac() { + InputStream inputStream = null; + try { + inputStream = new FileInputStream(new File(facPath+File.separator+"factory.fac")); + List list = ParseFacUtils.parsePoint(inputStream); + list.forEach(entity -> { + mqttSender.sendToMqtt(TopicConstant.TOPIC_DEVICE_MODEL, JsonUtil.toJson(entity)); + }); + return R.success("解析场信息文件成功"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return R.fail("解析场信息文件失败"); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @ApiOperation(value = "分页范围配置", notes = "分页范围配置") + @GetMapping("/pageGap") + public R> pageGap(String stationId, Query query) { + List list=simulationService.getDeviceListByStationId(stationId); + List ids=list.stream().map(Device::getId).collect(Collectors.toList()); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); + lambdaQueryWrapper.in(DeviceFieldGap::getFacDeviceId,ids); + IPage pageList=deviceFieldGapService.page(Condition.getPage(query),lambdaQueryWrapper); + return R.data(pageList); + } + + @ApiOperation(value = "更新设备属性范围配置", notes = "更新设备属性范围配置") + @PostMapping("/updateGap") + public R updateGap(@RequestBody DeviceFieldGap deviceFieldGap) { + deviceFieldGapService.updateById(deviceFieldGap); + return R.status(true); + } + + @ApiOperation(value = "第一次同步设备属性", notes = "第一次同步设备属性") + @GetMapping("/syncOneGap") + public R syncGap() { + //存在表 + int count=deviceFieldService.existGapTable(); + if(count<=0){//建表 + deviceFieldService.createGapTable(); + } + //同步 + List list=deviceFieldService.list(); + List gaps=list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), + result.getSignage(),result.getName(), BigDecimal.ZERO,BigDecimal.ZERO)) + .collect(Collectors.toList()); + deviceFieldGapService.saveOrUpdateBatch(gaps); + + return R.status(true); + } + + @ApiOperation(value = "第二次同步设备属性", notes = "第二次同步设备属性") + @GetMapping("/syncTwoGap") + public R syncTwoGap() { + //同步 + List list=deviceFieldService.queryNewInsert(); + if(list!=null && !list.isEmpty()) { + List gaps = list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), + result.getSignage(), result.getName(), BigDecimal.ZERO, BigDecimal.ZERO)) + .collect(Collectors.toList()); + deviceFieldGapService.saveBatch(gaps); + } + return R.status(true); + } + + + @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") + @GetMapping("/simulationMultiple") + public R simulationMultipleV3(String stationId, Long sleepTime) { + String key = "simulation:" + stationId; + String hasExc = cacheMap.get(key); + if (Func.isNotBlank(hasExc)) { + return R.fail("该站已经在模拟数据了"); + } + try { + simulationService.simulationMultiple(stationId, sleepTime); + }catch (Exception e) { + throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); + } + cacheMap.put(key, "true"); + return R.status(true); + + } + + @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") + @GetMapping("/simulationMultipleV4") + public R simulationMultipleV4(String stationId, Long sleepTime) { + String key = "simulation:" + stationId; + String hasExc = cacheMap.get(key); + if (Func.isNotBlank(hasExc)) { + return R.fail("该站已经在模拟数据了"); + } + try { + simulationService.simulationMultipleV4(stationId, sleepTime); + }catch (Exception e) { + throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); + } + cacheMap.put(key, "true"); + return R.status(true); + } + +// @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") +// @GetMapping("/simulationMultipleFlow") +// public R simulationMultipleInFlow() { +// String key = "simulationMultipleInFlow"; +// String hasExc = cacheMap.get(key); +// if (Func.isNotBlank(hasExc)) { +// return R.fail("该站已经在模拟数据了"); +// } +// simulationService.simulationMultipleInFlow(); +// cacheMap.put(key, "true"); +// return R.status(true); +// } + + + @ApiOperation(value = "停止模拟", notes = "停止模拟") + @GetMapping("/stopStart") + public R stopStart() { + simulationService.stopStart(); + return R.status(true); + + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java new file mode 100644 index 0000000..633cbb8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DataItem { + + private String id; + private String signage;//hz3000定义的id + private String name; + private String type; + private String soeType; + private String eventType; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java new file mode 100644 index 0000000..7771e95 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.Data; + +import java.util.List; + +/** + * { + * "station": "4543", + * "structType": "dataGroup", + * "id": "5016387599_0", + * "pid": "5016387585", + * "name": "温度传感器", + * "children": [{ + * "id": "5016387607", + * "name": "温度", + * "type": "YC" + * },{ + * "id": "5016387617", + * "name": "高度", + * "type": "YC" + * },{ + * "id": "5016387608", + * "name": "工作状态", + * "type": "YX" + * },{ + * "id": "5016387609", + * "name": "工作状态", + * "type": "SOE", + * "eventType": "" + * }] + * } + * 数据组 + * @author ninglong + */ +@Data +public class DataModel { + private String station; + private String structType; + private String id; + private String signage;//hz3000定义的id + private String pid; + private String name; + private List children; +} + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java new file mode 100644 index 0000000..b3ed590 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * 数据组 + * + * @author ninglong + */ +@TableName(value = "hzinfo_fac_device") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Device implements Serializable { + + @ApiModelProperty(value = "id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "0-云端cms,1-站端直传") + private Integer source; + + @ApiModelProperty("hz3000定义的id,如果定义的是大id则值与id字段值相同") + private String sid; + + @ApiModelProperty("version=v3,version=v4") + private String modelKind; + + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonSerialize( + using = ToStringSerializer.class + ) + + @ApiModelProperty("项目id") + private String projectId; + + + @ApiModelProperty("写入方式") + private String isWrite; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java new file mode 100644 index 0000000..411609c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.simulate.entity; + +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 设备数据 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DeviceData { + private String station; + private String time; + private List children = Lists.newArrayList(); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java new file mode 100644 index 0000000..6b6023d --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.entity; + +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DeviceDataV4 { + private String stationId; + private String time; + private List children = Lists.newArrayList(); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java new file mode 100644 index 0000000..80c449e --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author ysj + */ +@TableName("hzinfo_fac_device_config") +@Data +public class DeviceFacConfig implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty("设备id") + private String deviceCode; + + @ApiModelProperty("字段标识") + private String facDeviceId; + + @ApiModelProperty("站点Id") + private String stationId; + + @ApiModelProperty("站点类型") + private String modelKind; + + @ApiModelProperty("sid") + private String sid; + + @ApiModelProperty("数据写入方式: 1-闸门,2-天气") + private String writeMethod; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java new file mode 100644 index 0000000..c9660e2 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +@TableName("hzinfo_fac_device_attr") +@Data +public class DeviceField implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + @ApiModelProperty("设备id") + private String facDeviceId; + @ApiModelProperty("字段标识") + private String signage; + @ApiModelProperty("字段名称") + private String name; + @ApiModelProperty("最大值") + private String projectId; + + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty("创建时间") + private Date createTime; + + private Long modelClassifyId; + private String alarmType; + + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java new file mode 100644 index 0000000..d3efad5 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@TableName("hzinfo_fac_device_attr_gap") +@Data +@AllArgsConstructor +public class DeviceFieldGap implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + @ApiModelProperty("设备id") + private String facDeviceId; + @ApiModelProperty("字段标识") + private String signage; + @ApiModelProperty("字段名称") + private String name; + @ApiModelProperty("最大值") + private BigDecimal maxVal; + @ApiModelProperty("最小值") + private BigDecimal minVal; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java new file mode 100644 index 0000000..5363edd --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author ysj + */ +@TableName("hzinfo_fac_device_rain_gap") +@Data +public class DeviceRainGap implements Serializable { + + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty("设备id") + private String facDeviceId; + + @ApiModelProperty("属性标识名称") + private String name; + + @ApiModelProperty("属性标识") + private String attribute; + + @ApiModelProperty("字段标识") + private String signage; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java new file mode 100644 index 0000000..4a6c839 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Kvtq { + + private String k; + private String v; + private String t; + private Integer q; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java new file mode 100644 index 0000000..a5a8b0e --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class KvtqV4 { + private String sid; + private String k; + private String v; + private String t; + private Integer q; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java new file mode 100644 index 0000000..ad70ac9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceFacConfig; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ysj + */ +@Mapper +public interface DeviceFacConfigMapper extends BaseMapper { + + List queryConfigDevice(@Param("method") String method); + + DeviceFacConfig configByDeviceCode(@Param("deviceCode") String deviceCode); +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml new file mode 100644 index 0000000..1dda78c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java new file mode 100644 index 0000000..d3e85d4 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +@Mapper +public interface DeviceFieldGapMapper extends BaseMapper { + List queryDeviceLimits(@Param("signages") List signages); + + void updateLimitById(@Param("maxValue") BigDecimal maxValue, @Param("minValue") BigDecimal minValue,@Param("id") String id); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml new file mode 100644 index 0000000..7a4fff8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml @@ -0,0 +1,18 @@ + + + + + + + UPDATE HZINFO_FAC_DEVICE_ATTR_GAP + SET max_val = #{maxValue}, + min_val = #{minValue} + WHERE id = #{id} + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java new file mode 100644 index 0000000..e44fc5d --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceField; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface DeviceFieldMapper extends BaseMapper { + int existGapTable(); + int createGapTable(); + List queryNewInsert(); + + List queryDeviceFields(@Param("devices") List devices); + + List querySignages(@Param("facDeviceId") String facDeviceId); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml new file mode 100644 index 0000000..477ff69 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml @@ -0,0 +1,34 @@ + + + + + + CREATE TABLE hzinfo_device_field_gap ( + id varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字段类型', + fac_device_id varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '设备实例id', + signage varchar(25) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段标识', + name varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称', + max_val decimal(9,3) DEFAULT NULL, + min_val decimal(9,3) DEFAULT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='设备字段' + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java new file mode 100644 index 0000000..4edccd1 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.Device; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface DeviceMapper extends BaseMapper { + String getSid(@Param("stationId") String stationId); + +// List selectStcd(); +// +// int insertData(@Param("param") Map param); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml new file mode 100644 index 0000000..19587cf --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java new file mode 100644 index 0000000..5438aca --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceRainGap; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ysj + */ +@Mapper +public interface DeviceRainGapMapper extends BaseMapper { + + List RainGapByFacDeviceId(@Param("facDeviceId") String facDeviceId); +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml new file mode 100644 index 0000000..95d531a --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java new file mode 100644 index 0000000..3032379 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.simulate.scheduled; + +import com.hnac.hzims.simulate.constants.WriteRealDataConstant; +import com.hnac.hzims.simulate.service.WriteRealDataService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Date; + + +/** + * @author ysj + * @describe 实时数据写入定时任务 + */ +@Slf4j +@Component +public class WriteRealDataTask { + + @Autowired + private WriteRealDataService writeRealDataService; + + /** + * 设备模型信息 + */ + @XxlJob(WriteRealDataConstant.WRITE_REAL_GATE_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT writeRealGateData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + writeRealDataService.writeRealGateData(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 设备模型信息 + */ + @XxlJob(WriteRealDataConstant.WRITE_REAL_RAIN_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT writeRealRainData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + writeRealDataService.writeRealRainData(param); + return new ReturnT<>("SUCCESS"); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java new file mode 100644 index 0000000..99868bb --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; +import org.springframework.stereotype.Service; + +@Service +public class DeviceFieldGapService extends ServiceImpl { + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java new file mode 100644 index 0000000..c97b7e9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.DeviceField; +import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class DeviceFieldService extends ServiceImpl { + + public int existGapTable(){ + return this.baseMapper.existGapTable(); + } + + public int createGapTable(){ + return this.baseMapper.createGapTable(); + } + + public List queryNewInsert(){ + return this.baseMapper.queryNewInsert(); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java new file mode 100644 index 0000000..494b1e5 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.Device; +import com.hnac.hzims.simulate.mapper.DeviceMapper; +import org.springframework.stereotype.Service; + +@Service +public class DeviceService extends ServiceImpl { + public String getSid(String stationId){ + return this.baseMapper.getSid(stationId); + } + +// public List selectStcd(){ +// return this.baseMapper.selectStcd(); +// } +// +// public int insertData(Map param){ +// return this.baseMapper.insertData(param); +// } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java new file mode 100644 index 0000000..31903f9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java @@ -0,0 +1,280 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.hnac.hzims.simulate.entity.*; +import com.hnac.hzims.simulate.util.DataConstants; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.DateTimeUtil; +import org.springblade.core.tool.utils.ThreadUtil; +import org.springblade.mqtt.producer.IMqttSender; +import com.hnac.hzims.simulate.util.TopicConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class SimulationService { + @Autowired + IMqttSender mqttSender; + + @Autowired + DeviceService deviceService; + + @Autowired + DeviceFieldService deviceFieldService; + + @Autowired + DeviceFieldGapService deviceFieldGapService; + + public List getDeviceListByStationId(String projectId){ + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); + lambdaQueryWrapper.eq(Device::getProjectId,projectId); + lambdaQueryWrapper.eq(Device::getIsWrite,"0"); + List list = deviceService.list(lambdaQueryWrapper); + return list; + } + + String getSid(String stationId){ + return deviceService.getSid(stationId); + } + + //模拟启停标识 + private volatile boolean flag=true; + + public void stopStart(){ + flag = !flag; + } + + @Async + public void simulationMultiple(String stationId, Long sleepTime) { + + List list = getDeviceListByStationId(stationId); + //查询所有属性 + List fieldList = deviceFieldService.list(); + List gapList = deviceFieldGapService.list(); + + log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); + while (true) { + if (flag) {//启动或关闭模拟 + for (Device device : list) { + Map map = simulation(stationId, device,fieldList,gapList); +// log.info("map data: "+ JsonUtil.toJson(map)); + if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { + log.info("模拟推送遥测,主题:topic_hzinfo_props:{}", JsonUtil.toJson(map.get("yc"))); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(map.get("yc"))); + } +// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { +// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); +// } + if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(map.get("yx"))); + } + } + //最小10毫秒 + if (sleepTime == null || sleepTime == 0) { + sleepTime = 10L; + } + ThreadUtil.sleep(sleepTime); + } + } + } + + +// @Async +// public void simulationMultipleInFlow(){ +// List list=deviceService.selectStcd(); +// while (true) { +// List> datas = simulationFlow(list); +// for(Map param:datas){ +// deviceService.insertData(param); +// } +// ThreadUtil.sleep(3600000); +// } +// } + + private List> simulationFlow(List list){ + List> datas =new ArrayList<>(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dt=sdf.format(new Date()); + for(String stcd:list){ + Map data=new HashMap<>(); + String value = getRandomRedPacketBetweenMinAndMax(new BigDecimal("0"), new BigDecimal("20")).toString(); + data.put("stcd",stcd); + data.put("dt",dt); + data.put("inflow",value); + datas.add(data); + } + return datas; + } + + + @Async + public void simulationMultipleV4(String stationId, Long sleepTime){ + String sid=getSid(stationId); + List list = getDeviceListByStationId(stationId); + //查询所有属性 + List fieldList = deviceFieldService.list(); + List gapList = deviceFieldGapService.list(); + + log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); + while (true) { + if (flag) {//启动或关闭模拟 + for (Device device : list) { + Map map = simulationV4(stationId,sid, device,fieldList,gapList); + //log.info("map data: "+ JsonUtil.toJson(map)); + if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { + mqttSender.sendToMqtt("hzinfo_v4_yc", JsonUtil.toJson(map.get("yc"))); + } +// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { +// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); +// } + if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { + mqttSender.sendToMqtt("hzinfo_v4_yx", JsonUtil.toJson(map.get("yx"))); + } + } + //最小10毫秒 + if (sleepTime == null || sleepTime == 0) { + sleepTime = 10L; + } + ThreadUtil.sleep(sleepTime); + } + } + } + + public static BigDecimal getRandomRedPacketBetweenMinAndMax(BigDecimal min, BigDecimal max){ + float minF = min.floatValue(); + float maxF = max.floatValue(); + //生成随机数 + BigDecimal db = new BigDecimal(Math.random() * (maxF - minF) + minF); + //返回保留两位小数的随机数。不进行四舍五入 + return db.setScale(3,BigDecimal.ROUND_DOWN); + } + + public static int getIntBetweenMinAndMax(int min, int max){ + //生成随机数 + int randomNum = min + (int)(Math.random() * ((max - min) + 1)); + //返回保留两位小数的随机数。不进行四舍五入 + return randomNum; + } + + /** + * 模拟一条数据 + */ + private Map simulation(String stationId, Device device,List fieldListAll,List gapListAll) { +// List fieldList = getListByDeviceId(device.getId()); +// List gapList = getListByDeviceGapId(device.getId()); + List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); + List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); +// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); +// log.info("gapList data: "+ JsonUtil.toJson(gapList)); + List ycList = Lists.newArrayList(); + List yxList = Lists.newArrayList(); + //List ddList = Lists.newArrayList(); + for (DeviceField field : fieldList) { + Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); + + if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); + Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + ycList.add(kvtq); + } + } +// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { +// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); +// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); +// ddList.add(kvtq); +// } + if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); + Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + yxList.add(kvtq); + } + } + } + Map map = Maps.newHashMap(); + if (ycList.size() > 0) { + map.put("yc", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); + } +// if (ddList.size() > 0) { +// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); +// } + if (yxList.size() > 0) { + map.put("yx", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); + } + return map; + } + + + private Map simulationV4(String stationId,String sid, Device device,List fieldListAll,List gapListAll) { + +// List fieldList = getListByDeviceId(device.getId()); +// List gapList = getListByDeviceGapId(device.getId()); + List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); + List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); +// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); +// log.info("gapList data: "+ JsonUtil.toJson(gapList)); + List ycList = Lists.newArrayList(); + List yxList = Lists.newArrayList(); + //List ddList = Lists.newArrayList(); + for (DeviceField field : fieldList) { + Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); + + if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); + KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + ycList.add(kvtq); + } + } +// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { +// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); +// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); +// ddList.add(kvtq); +// } + if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); + KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + yxList.add(kvtq); + } + } + } + Map map = Maps.newHashMap(); + if (ycList.size() > 0) { + map.put("yc", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); + } +// if (ddList.size() > 0) { +// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); +// } + if (yxList.size() > 0) { + map.put("yx", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); + } + return map; + } + + private List getListByDeviceId(String deviceId) { + return deviceFieldService.list(Wrappers.lambdaQuery().ne(DeviceField::getModelClassifyId, DataConstants.DeviceDataType.SOE.name()).eq(DeviceField::getFacDeviceId, deviceId)); + } + + private List getListByDeviceGapId(String deviceId){ + return deviceFieldGapService.list(Wrappers.lambdaQuery().eq(DeviceFieldGap::getFacDeviceId, deviceId)); + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java new file mode 100644 index 0000000..ed500f3 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.simulate.service; + +/** + * @author ysj + */ +public interface WriteRealDataService { + + void writeRealGateData(String param); + + void writeRealRainData(String param); + + Boolean isOpen(String deviceCode, Long isOpen); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java new file mode 100644 index 0000000..4a49938 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java @@ -0,0 +1,304 @@ +package com.hnac.hzims.simulate.service.impl; + +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; +import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; +import com.hnac.hzims.simulate.constants.WriteRealDataConstant; +import com.hnac.hzims.simulate.entity.*; +import com.hnac.hzims.simulate.mapper.DeviceFacConfigMapper; +import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; +import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; +import com.hnac.hzims.simulate.mapper.DeviceRainGapMapper; +import com.hnac.hzims.simulate.service.WriteRealDataService; +import com.hnac.hzims.simulate.util.DataConstants; +import com.hnac.hzims.simulate.util.TopicConstant; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.*; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V3; +import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V4; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class WriteRealDataServiceImpl implements WriteRealDataService { + + private final IEmInfoClient deviceClient; + + private final IHeWeatherWeatherClient weatherClient; + + private final IMqttSender mqttSender; + + private final DeviceFieldMapper fieldMapper; + + private final DeviceFieldGapMapper limitMapper; + + private final DeviceFacConfigMapper configMapper; + + private final DeviceRainGapMapper deviceRainGapMapper; + + /** + * 实时数据写入 + * @param param + */ + @Override + public void writeRealGateData(String param) { + // 查询设备配置 + List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_GATE); + if(CollectionUtil.isEmpty(configs)){ + return; + } + //#.000 表示三位小数 + DecimalFormat df = new DecimalFormat("#0.000"); + // 遍历发送mqtt实时数据 + configs.stream().collect(Collectors.groupingBy(DeviceFacConfig::getModelKind)).forEach((modeKind,groups)->{ + // 查询设备属性 + List fields = fieldMapper.queryDeviceFields(groups.stream().map(DeviceFacConfig::getFacDeviceId).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(fields)){ + return; + } + // 查询设备限制 + List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(limits)){ + return; + } + // v3 + if(REAL_DATA_V3.equals(modeKind)){ + fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)-> { + // 遥测实时数据对象 + List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new Kvtq(); + } + Kvtq real = new Kvtq(); + double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(ycs)) { + log.error("yc_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + } + // 遥信实时数据对象 + List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new Kvtq(); + } + Kvtq real = new Kvtq(); + double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + })); + } + // v4 + if(REAL_DATA_V4.equals(modeKind)){ + fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)->{ + // 遥测实时数据对象 + List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new KvtqV4(); + } + // 查找sid + Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); + if(!sid.isPresent()){ + return new KvtqV4(); + } + KvtqV4 real = new KvtqV4(); + double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setSid(sid.get().getSid()); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(ycs)) { + log.error("yc_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YC,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + } + // 遥信实时数据对象 + List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new KvtqV4(); + } + // 查找sid + Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); + if(!sid.isPresent()){ + return new KvtqV4(); + } + KvtqV4 real = new KvtqV4(); + double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setSid(sid.get().getSid()); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + })); + } + }); + } + + /** + * 雨量站实时数据写入 + * @param param + */ + @Override + public void writeRealRainData(String param) { + // 查询设备配置 + List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_RAIN); + if(CollectionUtil.isEmpty(configs)){ + return; + } + R> devices = deviceClient.getEmInfoByEmCodes(configs.stream().map(DeviceFacConfig::getDeviceCode).collect(Collectors.toList())); + if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ + return; + } + devices.getData().forEach(device->{ + if(ObjectUtil.isEmpty(device.getLgtd()) || ObjectUtil.isEmpty(device.getLttd())){ + return; + } + // 查询设备经纬度 + String location = device.getLgtd() + "," + device.getLttd(); + R weather = weatherClient.getWeatherNowWithCache(location); + if(!weather.isSuccess() || ObjectUtil.isEmpty(weather.getData()) || ObjectUtil.isEmpty(weather.getData().getNow())){ + return; + } + Optional optional = configs.stream().filter(o->o.getDeviceCode().equals(device.getNumber())).findFirst(); + if(!optional.isPresent()){ + return; + } + List deviceRainGap = deviceRainGapMapper.RainGapByFacDeviceId(optional.get().getFacDeviceId()); + if(CollectionUtil.isEmpty(deviceRainGap)){ + return; + } + List yxs = deviceRainGap.stream().map(o->{ + KvtqV4 real = new KvtqV4(); + real.setSid(optional.get().getSid()); + real.setK(o.getSignage()); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + if(WriteRealDataConstant.ATTR_RAIN.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getPrecip()); + }else if(WriteRealDataConstant.ATTR_WIND360.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWind360()); + }else if(WriteRealDataConstant.ATTR_WIND_SCALE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWindScale()); + }else if(WriteRealDataConstant.ATTR_WIND_SPEED.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWindSpeed()); + }else if(WriteRealDataConstant.ATTR_HUMIDITY.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getHumidity()); + }else if(WriteRealDataConstant.ATTR_PRESSURE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getPressure()); + }else if(WriteRealDataConstant.ATTR_VIS.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getVis()); + }else if(WriteRealDataConstant.ATTR_CLOUD.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getCloud()); + }else if(WriteRealDataConstant.ATTR_DEW.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getDew()); + }else if(WriteRealDataConstant.ATTR_FEELS_LIKE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getFeelsLike()); + }else if(WriteRealDataConstant.ATTR_TEMP.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getTemp()); + } + if(StringUtil.isEmpty(real.getV())){ + real.setV("0.0"); + } + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + }); + } + + /** + * 开启/关闭闸门数据 + * @param deviceCode + * @param isOpen + * @return + */ + @Override + public Boolean isOpen(String deviceCode, Long isOpen) { + // 查询写入设备配置 + DeviceFacConfig config = configMapper.configByDeviceCode(deviceCode); + if(ObjectUtil.isEmpty(config)){ + return false; + } + // 查询设备属性 + List fields = fieldMapper.querySignages(config.getFacDeviceId()); + if(CollectionUtil.isEmpty(fields)){ + return false; + } + // 查询属性限制 + List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(limits)){ + return false; + } + limits.forEach(limit->{ + Optional optional = fields.stream().filter(o->o.getSignage().equals(limit.getSignage())).findFirst(); + if(!optional.isPresent()){ + return; + } + String signage = optional.get().getName(); + if(WriteRealDataConstant.GATE_STATUS.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.ONE,BigDecimal.ZERO,limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + }else if(WriteRealDataConstant.GATE_FLOW.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.valueOf(3560.000),BigDecimal.valueOf(0.000),limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + }else if(WriteRealDataConstant.OPENING_DEGREE.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.valueOf(10),BigDecimal.valueOf(0.000),limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + } + }); + return true; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java new file mode 100644 index 0000000..a4873df --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java @@ -0,0 +1,357 @@ +package com.hnac.hzims.simulate.util; + +public interface DataConstants { + String REDIS_MESSAGE_TOPIC = "hzinfo_config_message_topic"; + String TIME_COLUMN = "ts"; + String VALUE_COLUMN = "val"; + String Q_COLUMN = "q"; + String REAL_ID_COLUMN = "realid"; + String TBNAME = "tbname"; + String YC_TABLE_PREFIX = "yc_"; + String YX_TABLE_PREFIX = "yx_"; + String SOE_TABLE_PREFIX = "soe_"; + String SOE_ALARM_TABLE_PREFIX = "soe_alarm_"; + String YC = "YC"; + String YX = "YX"; + String SOE = "SOE"; + String YK_RETURN_PREFIX = "ykfj:"; + String REALID_CALCULATE = "16777215"; + String DEVICE_SUPER_TABLE_PREFIX = "hz_"; + String DEVICE_TABLE_PREFIX = "d_"; + + public static enum DataStructTypeEnum { + struct, + dataGroup; + + private DataStructTypeEnum() { + } + } + + public static enum EYkRetStatus { + yrsSuccess, + yrsServerErr, + yrsChannelErr, + yrsModuleErr, + yrsDeviceTimeOut, + yrsDeviceFail, + yrsExpired; + + private EYkRetStatus() { + } + } + + public static enum SoeType { + skNone(0, "0", "默认"), + skSys(1, "1", "系统"), + skAlarm(2, "2", "报警"), + skAct(3, "3", "事故"), + skOperate(4, "4", "用户操作"), + skYcOut(5, "5,11,12", "遥测越限"), + skYxChange(6, "6,10", "遥信变位"), + skReg(7, "7", "注册信息"), + skHint(8, "8", "信息提示"), + skInspect(9, "9", "设备巡检"), + skMonitorOperate(10, "13,14", "遥控操作"), + skRDSYcOutOfLimitResume(11, "15", "遥测越限恢复"), + skUndefine(12, "16,17,18", "未定义"), + skNetworkAnomaly(13, "-1", "通讯异常"), + skCommunicateAnomaly(14, "-2", "数据异常"); + + private Integer index; + private String soeKind; + private String name; + + private SoeType(Integer index, String soeKind, String name) { + this.index = index; + this.soeKind = soeKind; + this.name = name; + } + + public static String getName(Integer id) { + SoeType[] values = values(); + + for (int i = 0; i < values.length; ++i) { + if (values[i].index.equals(id)) { + return values[i].getName(); + } + } + + return null; + } + + public static Integer getIndexBySoeKind(String soeType) { + SoeType[] values = values(); + SoeType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + SoeType type = var2[var4]; + if (type.getSoeKind().contains(soeType)) { + return type.getIndex(); + } + } + + return skUndefine.getIndex(); + } + + public static String getSoeKindByIndex(Integer index) { + SoeType[] values = values(); + SoeType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + SoeType type = var2[var4]; + if (type.getIndex().equals(index)) { + return type.getSoeKind(); + } + } + + return ""; + } + + public Integer getIndex() { + return this.index; + } + + public String getSoeKind() { + return this.soeKind; + } + + public String getName() { + return this.name; + } + } + + public static enum SoeKind { + skNone(0, "默认"), + skSys(1, "系统"), + skAlarm(2, "报警"), + skAct(3, "事故"), + skOperate(4, "操作"), + skYcOut(5, "遥测越限(告警)"), + skYxChange(6, "遥信变位(告警)"), + skReg(7, "注册信息"), + skHint(8, "信息提示"), + skInspect(9, "设备巡检"), + skRDSYxChange(10, "遥信变位(数据)"), + skRDSYcOutOfLimit(11, "遥测越上/下限(数据)"), + skRDSYcOutOfLimit2(12, "遥测越上上/下下限(数据)"), + skMonitorOperate(13, "操作记录(遥控)"), + skMonitorOperateII(14, "操作记录(写定值)"), + skRDSYcOutOfLimitResume(15, "越限恢复"), + bak_7(16, "备用7"), + bak_8(17, "备用8"), + skUndefine(18, "未定义"); + + private Integer index; + private String name; + + private SoeKind(Integer index, String name) { + this.index = index; + this.name = name; + } + + public static String getName(Integer id) { + SoeKind[] values = values(); + + for (int i = 0; i < values.length; ++i) { + if (values[i].index.equals(id)) { + return values[i].getName(); + } + } + + return null; + } + + public Integer getIndex() { + return this.index; + } + + public String getName() { + return this.name; + } + } + + public static enum DeviceDataType { + YC("遥测"), + YX("遥信"), + DD("电渡"), + YK("遥控"), + YT("遥调"), + SOE("事件"), + STR("字符串"), + OTHER("其它"); + + private String displayName; + + private DeviceDataType(String displayName) { + this.displayName = displayName; + } + + public static String getDisplayName(String name) { + DeviceDataType type = valueOf(name); + return type.getDisplayName(); + } + + public String getDisplayName() { + return this.displayName; + } + } + + public static enum YkDelayType { + none_store, + store, + delay_store; + + private YkDelayType() { + } + } + + public static enum RedisGroupMessageTypeEnum { + NOTICE_CLEAN_LOCAL_CACHE_DEVICE("clean.local.cache.device"), + NOTICE_CLEAN_LOCAL_CACHE_DEVICE_GROUP("clean.local.cache.group"), + NOTICE_CLEAN_LOCAL_CACHE_ALARM("clean.local.cache.alarm"), + NOTICE_CLEAN_LOCAL_CACHE_YK("clean.local.cache.yk"); + + private String value; + + private RedisGroupMessageTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + } + + public static enum DataStatusEnum { + offline, + online; + + private DataStatusEnum() { + } + } + + public static enum StatisticsType { + avg("AVG"), + max("MAX"), + min("MIN"); + + private String computeStrategy; + + private StatisticsType(String fun) { + this.computeStrategy = fun; + } + + public static StatisticsType getStatisticsType(int index) { + StatisticsType[] values = values(); + StatisticsType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + StatisticsType value = var2[var4]; + if (index == value.ordinal()) { + return value; + } + } + + return null; + } + + public String getComputeStrategy() { + return this.computeStrategy; + } + + public void setComputeStrategy(final String computeStrategy) { + this.computeStrategy = computeStrategy; + } + } + + public static enum AnalyzeInstanceAlarmConfType { + changeAlarm("变化告警"), + supassAlarm("越限告警"); + + private String name; + + private AnalyzeInstanceAlarmConfType(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + } + + public static enum StatisticsAnalyEnum { + Hour("h"), + Day("d"), + Month("n"), + Year("h"); + + private String type; + + private StatisticsAnalyEnum(String fun) { + this.type = fun; + } + + public static StatisticsAnalyEnum getStatisticsAnalyEnum(int index) { + StatisticsAnalyEnum[] values = values(); + StatisticsAnalyEnum[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + StatisticsAnalyEnum value = var2[var4]; + if (value.ordinal() == index) { + return value; + } + } + + return null; + } + + public String getType() { + return this.type; + } + } + + public static enum StationFromSouceEnum { + cloud, + station; + + private StationFromSouceEnum() { + } + } + + public static enum AnalyzeInstanceDataResoureEnum { + deviceUp("设备上报"), + hz3000Up("华自网关上报"); + + private String name; + + private AnalyzeInstanceDataResoureEnum(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + } + + public static enum ThresholdLevelEnum { + one, + two, + three; + + private ThresholdLevelEnum() { + } + } + + public static enum Hz3000VersionEnum { + v3, + v4; + + private Hz3000VersionEnum() { + } + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java new file mode 100644 index 0000000..34d7437 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java @@ -0,0 +1,105 @@ +package com.hnac.hzims.simulate.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.collect.Lists; +import com.hnac.hzims.simulate.entity.DataItem; +import com.hnac.hzims.simulate.entity.DataModel; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.xml.sax.SAXException; + +import java.io.InputStream; +import java.math.BigInteger; +import java.util.List; + +/** + * 解析厂信息工具类 + * @author ninglong + */ +public class ParseFacUtils { + + public static List parsePoint(InputStream inputStream) throws SAXException, DocumentException, JsonProcessingException { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(inputStream); + List groupElements = document.selectNodes("/Factorys/Factory/Group"); + List list = parseDataGroup(groupElements); + List ycElements = document.selectNodes("/Factorys/Factory/Group/AIS/AI"); + list = pastePointElement(ycElements, DataConstants.DeviceDataType.YC.name(),list); + + List yxElements = document.selectNodes("/Factorys/Factory/Group/DIS/DI"); + list = pastePointElement(yxElements, DataConstants.DeviceDataType.YX.name(),list); + + List ddElements = document.selectNodes("/Factorys/Factory/Group/DDS/DD"); + list = pastePointElement(ddElements, DataConstants.DeviceDataType.DD.name(),list); + + List soeElements = document.selectNodes("/Factorys/Factory/Group/SOES/SOE"); + list = pastePointElement(soeElements, DataConstants.DeviceDataType.SOE.name(),list); + + List ykElements = document.selectNodes("/Factorys/Factory/Group/DOS/DO"); + list = pastePointElement(ykElements, DataConstants.DeviceDataType.YK.name(),list); + return list; + } + + /** + * 解析数据组 + */ + private static List parseDataGroup(List elements){ + List list = Lists.newArrayList(); + for (Element element : (List) elements) { + DataModel model = new DataModel(); + model.setStructType(DataConstants.DataStructTypeEnum.dataGroup.name()); + model.setId(element.attribute("ID").getValue()); + model.setSignage(bigId2SmallId(element.attribute("ID").getValue())); + model.setName(element.attribute("Name").getValue()); + String stationNumStr = element.getParent().attribute("StationNum").getValue(); + model.setStation(stationNumStr); + list.add(model); + } + return list; + } + + /** + * 将大id转换成小id + */ + public static String bigId2SmallId(String realId){ + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); + } + /** + * 解析数据点 + */ + private static List pastePointElement(List elements, String type, List list) throws JsonProcessingException { + for (Element element : (List) elements) { + String groupId = element.getParent().getParent().attribute("ID").getValue(); + for(DataModel dm:list){ + if(!groupId.equals(dm.getId())){ + continue; + } + DataItem dataItem = DataItem.builder() + .id(element.attribute("ID").getValue()) + .signage(bigId2SmallId(element.attribute("ID").getValue())) + .name(element.attribute("Name").getValue()) + .type(type) + .build(); + if(DataConstants.DeviceDataType.SOE.name().equals(type)){ + dataItem.setEventType(element.attribute("SOEAlarmType").getValue()); + dataItem.setSoeType(element.attribute("SOEType").getValue()); + } + if(DataConstants.DeviceDataType.YX.name().equals(type)){ + dataItem.setEventType(element.attribute("YXAlarmType").getValue()); + dataItem.setSoeType(element.attribute("SOEType").getValue()); + } + List childrens = dm.getChildren(); + if(childrens==null){ + childrens = Lists.newArrayList(); + } + childrens.add(dataItem); + dm.setChildren(childrens); + } + } + return list; + } +} + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java new file mode 100644 index 0000000..f5d3282 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.simulate.util; + + +import java.math.BigInteger; + +public class RealIdConvertUtils { + + private void demo() { + BigInteger ss = new BigInteger("16777215"); + BigInteger s = new BigInteger("15122982502953650999"); + BigInteger stationId = s.shiftRight(24); + System.out.println(stationId.toString()); + BigInteger realId = s.and(ss); + System.out.println(realId.toString()); + + BigInteger xxx = stationId.shiftLeft(24); + BigInteger yyy = xxx.or(realId); + System.out.println(s.toString()); + System.out.println(yyy.toString()); + } + + /** + * 将大id转换成小id + */ + public static String bigId2SmallId(String realId) { + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); + } + + /** + * 将小id转换成大id + */ + public static String smallId2BigId(String station, String realId) { + BigInteger stationId = new BigInteger(station); + BigInteger BigRealId = stationId.shiftLeft(24).or(new BigInteger(realId)); + return BigRealId.toString(); + } + +// public static void main(String[] args) { +// System.out.println(RealIdConvertUtils.getStationId("262952509021093892")); +// System.out.println(RealIdConvertUtils.bigId2SmallId("262952509021093892")); +// System.out.println(smallId2BigId("15673190893", "32")); +// } + + /** + * 获取站点id + */ + public static String getStationId(String realId) { + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.shiftRight(24).toString(); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java new file mode 100644 index 0000000..1d4a8ca --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.util; + +public interface TopicConstant { + String TOPIC_DEVICE_MODEL = "topic_device_model"; + String TOPIC_HZINFO_PROPS = "topic_hzinfo_props"; + String TOPIC_HZINFO_V4_YC = "hzinfo_v4_yc"; + + String TOPIC_HZINFO_V4_YX = "hzinfo_v4_yx"; + + String TOPIC_HZINFO_YX = "topic_hzinfo_yx"; + String TOPIC_HZINFO_DD = "topic_hzinfo_dd"; + String TOPIC_HZINFO_EVENTS = "topic_hzinfo_events"; + String TOPIC_HZINFO_EVENTS_ALARM = "topic_hzinfo_events_alarm"; + String TOPIC_HZINFO_CONTROL_RETURN = "topic_hzinfo_control_return"; + String TOPIC_HZINFO_HEART_BEAT = "topic_hzinfo_heart_beat"; + String TOPIC_HZINFO_BROADCAST = "topic_hzinfo_broadcast"; + String TOPIC_HZINFO_DATA = "topic_hzinfo_data"; +} diff --git a/hzims-service/hzims-simulate/src/main/resources/application-dev.yml b/hzims-service/hzims-simulate/src/main/resources/application-dev.yml new file mode 100644 index 0000000..0abb9d3 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application-dev.yml @@ -0,0 +1,13 @@ +#服务器端口 +server: + port: 8211 + +#数据源配置 +spring: + datasource: + url: ${blade.datasource.dev.url} + username: ${blade.datasource.dev.username} + password: ${blade.datasource.dev.password} + cloud: + inetutils: + preferred-networks: 192.168.65 diff --git a/hzims-service/hzims-simulate/src/main/resources/application-prod.yml b/hzims-service/hzims-simulate/src/main/resources/application-prod.yml new file mode 100644 index 0000000..a96da50 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application-prod.yml @@ -0,0 +1,6 @@ +#数据源配置 +spring: + datasource: + url: ${blade.datasource.prod.url} + username: ${blade.datasource.prod.username} + password: ${blade.datasource.prod.password} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/resources/application.yml b/hzims-service/hzims-simulate/src/main/resources/application.yml new file mode 100644 index 0000000..61e8ff7 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application.yml @@ -0,0 +1,15 @@ +spring: + application: + name: lewa-simulate + +#mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath:org/springbalde/**/mapper/*Mapper.xml,classpath:com/hnac/hzinfo/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: org.springbalde.**.entity,com.hnac.hzinfo.**.entity + +#swagger扫描路径配置 +swagger: + base-packages: + - org.springbalde + - com.hnac.hzinfo \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java index 4dc814a..bba9770 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java @@ -28,8 +28,8 @@ public class HikVideoController extends BladeController { @ApiOperation("查询区域列表") @ApiOperationSupport(order = 1) @GetMapping("/nodesByParams") - public R> nodesByParams(@ApiParam("区域父级编号")@RequestParam(required = false) String parentIndexCode) { - return R.data(hikVideoService.nodesByParams(parentIndexCode)); + public R> nodesByParams(@RequestParam(value = "platformId",required = false) Long platformId,@ApiParam("区域父级编号")@RequestParam(value = "parentIndexCode",required = false) String parentIndexCode) { + return R.data(hikVideoService.nodesByParams(platformId,parentIndexCode)); } @ApiOperation("根据区域获取下级编码设备列表") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index e048147..3639cb9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -319,8 +319,8 @@ public class StationVideoTypeController extends BladeController { @GetMapping("/getHikVideoAreaTree") @ApiOperationSupport(order = 150) @ApiOperation(value = "获取海康区域树", notes = "获取海康区域树") - public R> getHikVideoAreaTree() { - return R.data(stationVideoTypeService.getHikVideoAreaTree()); + public R> getHikVideoAreaTree(@RequestParam(value = "platformId",required = false)Long platformId) { + return R.data(stationVideoTypeService.getHikVideoAreaTree(platformId)); } @GetMapping("/getVideoPointByRegion") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java index 48d874b..e680dcd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java @@ -15,7 +15,7 @@ public interface IHikVideoService { * 查询区域列表 * @return 区域列表 */ - List nodesByParams(String parentIndexCode); + List nodesByParams(Long platformId,String parentIndexCode); List subResources(String regionIndexCode); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index 24da4a6..f008b57 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -77,7 +77,7 @@ public interface IStationVideoTypeService extends BaseService getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType); - List getHikVideoAreaTree(); + List getHikVideoAreaTree(Long platformId); Map getVideoPointByRegion(Long refDept,String regionCode); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java index 3c8795f..f3fd0ea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -7,15 +7,20 @@ import com.hikvision.artemis.sdk.ArtemisHttpUtil; import com.hikvision.artemis.sdk.config.ArtemisConfig; import com.hnac.hzims.operational.station.service.IHikVideoService; import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; +import com.hnac.hzims.operational.video.entity.VideoPlatformEntity; +import com.hnac.hzims.operational.video.service.IVideoPlatformService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,6 +32,8 @@ import static com.hnac.hzims.operational.station.constants.HikApiConstants.*; @Service public class HikVideoServiceImpl implements IHikVideoService { + private final IVideoPlatformService videoPlatformService; + @Value("${hzims.videoProperties.appKey}") private String videoAppKey; @@ -53,8 +60,20 @@ public class HikVideoServiceImpl implements IHikVideoService { } @Override - public List nodesByParams(String parentIndexCode) { - init(); + public List nodesByParams(Long platformId,String parentIndexCode) { + if(ObjectUtil.isEmpty(platformId)){ + init(); + }else{ + // 查询多平台配置 + VideoPlatformEntity platform = videoPlatformService.getById(platformId); + if(ObjectUtil.isEmpty(platform)){ + return new ArrayList<>(); + } + ArtemisConfig.host = platform.getVideoHost(); + ArtemisConfig.appKey = platform.getAppKey(); + ArtemisConfig.appSecret = platform.getAppSecret(); + } + Map path = new HashMap<>(); path.put("https://", ARTEMIS_PATH + NODE_BY_PARAMS); HashMap body = new HashMap() {{ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index 1b96b23..94e544a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -235,8 +235,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl getHikVideoAreaTree() { - List hikVideoAreaList = hikVideoService.nodesByParams(null); + public List getHikVideoAreaTree(Long platformId) { + List hikVideoAreaList = hikVideoService.nodesByParams(platformId,null); Map> videoAreaMapByParent = hikVideoAreaList.stream().collect(Collectors.groupingBy(HikVideoAreaVO::getParentIndexCode)); List firstLevelArea = videoAreaMapByParent.get("-1"); List result = firstLevelArea.stream().map(area -> this.generateAreaTree(videoAreaMapByParent, area)).collect(Collectors.toList()); diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index 3bd858a..8c59a54 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -29,6 +29,8 @@ hzims-alarm hzims-basic hzims-big-model + suichang + hzims-simulate diff --git a/hzims-service/spare/Dockerfile b/hzims-service/spare/Dockerfile deleted file mode 100644 index 453af19..0000000 --- a/hzims-service/spare/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM adoptopenjdk/openjdk8-openj9:alpine-slim - -MAINTAINER smallchill@163.com - -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories - -RUN apk add -U tzdata \ - && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk add --no-cache bash bash-doc bash-completion \ - && apk del tzdata \ - && rm -rf /var/cache/apk/* - -RUN mkdir -p /blade/desk - -WORKDIR /blade/desk - -EXPOSE 8105 - -ADD ./target/blade-demo.jar ./app.jar - -ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar - -CMD ["--spring.profiles.active=test"] diff --git a/hzims-service/spare/pom.xml b/hzims-service/spare/pom.xml deleted file mode 100644 index 88c1e6d..0000000 --- a/hzims-service/spare/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - com.hnac.hzims - hzims-service - 4.0.0-SNAPSHOT - - - 4.0.0 - - spare - ${project.artifactId} - ${bladex.project.version} - jar - - - - org.springblade - blade-core-boot - - - org.springblade - blade-starter-swagger - - - org.springblade - blade-starter-oss-all - - - com.hnac.hzims - spare-api - ${hzims.project.version} - - - com.baomidou - dynamic-datasource-spring-boot-starter - 2.5.6 - - - org.springblade - blade-core-test - test - - - org.springblade - blade-core-auto - provided - - - - - - com.hnac.hzinfo - common-asm-api - 0.0.1-SNAPSHOT - - - com.github.miemiedev - mybatis-paginator - - - com.sun.media - jai-codec - - - - - - - - - com.spotify - dockerfile-maven-plugin - - ${docker.username} - ${docker.password} - ${docker.registry.url}/${docker.namespace}/${project.artifactId} - ${project.version} - true - - target/${project.build.finalName}.jar - - true - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/SpareApplication.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/SpareApplication.java deleted file mode 100644 index a506e43..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/SpareApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare; - -import org.mybatis.spring.annotation.MapperScan; -import org.springblade.core.cloud.feign.EnableBladeFeign; -import org.springblade.core.launch.BladeApplication; -import org.springblade.core.launch.constant.AppConstant; -import org.springframework.cloud.client.SpringCloudApplication; - -/** - * Demo启动器 - * - * @author Chill - */ -@EnableBladeFeign -@SpringCloudApplication -@MapperScan("com.hnac.hzims.spare.**.mapper.**") -public class SpareApplication { - - public static void main(String[] args) { - BladeApplication.run("hzims-spare", SpareApplication.class, args); - } - -} - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/config/DemoConfiguration.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/config/DemoConfiguration.java deleted file mode 100644 index 8768e01..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/config/DemoConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.config; - - -import com.hnac.hzims.spare.props.DemoProperties; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -/** - * 配置feign、mybatis包名、properties - * - * @author Chill - */ -@Configuration -@EnableFeignClients({"org.springblade", "com.example"}) -@MapperScan({"org.springblade.**.mapper.**", "com.example.**.mapper.**"}) -@EnableConfigurationProperties(DemoProperties.class) -public class DemoConfiguration { - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DemoController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DemoController.java deleted file mode 100644 index 46812d9..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DemoController.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.controller; - -import com.hnac.hzims.spare.props.DemoProperties; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Demo控制器 - * - * @author Chill - */ -@RefreshScope -@RestController -@RequestMapping("demo") -@Api(value = "配置接口", tags = "即时刷新配置") -public class DemoController { - - @Value("${demo.name}") - private String name; - - private final DemoProperties properties; - - public DemoController(DemoProperties properties) { - this.properties = properties; - } - - - @GetMapping("name") - public String getName() { - return name; - } - - @GetMapping("name-by-props") - public String getNameByProps() { - return properties.getName(); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DynamicController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DynamicController.java deleted file mode 100644 index 2b7e8db..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/DynamicController.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.controller; - -import com.hnac.hzims.spare.entity.Notice; -import com.hnac.hzims.spare.service.IDynamicService; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * 多数据源 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("dynamic") -@Api(value = "多数据源接口", tags = "多数据源") -public class DynamicController { - - private final IDynamicService dynamicService; - - /** - * master列表 - */ - @GetMapping("/master-list") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "master列表", notes = "master列表") - public R> masterList() { - List list = dynamicService.masterList(); - return R.data(list); - } - - /** - * slave列表 - */ - @GetMapping("/slave-list") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "slave列表", notes = "slave列表") - public R> slaveList() { - List list = dynamicService.slaveList(); - return R.data(list); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeDetailController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeDetailController.java deleted file mode 100644 index c159e2a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeDetailController.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.hnac.hzims.spare.service.IHzimsSpChangeDetailService; -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * 备品备件出入库详情 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/hzims-spare/spChangeDetail") -@Api(value = "备品备件出入库详情", tags = "备品备件出入库详情") -public class HzimsSpChangeDetailController extends BladeController { - - private final IHzimsSpChangeDetailService spChangeDetailService; -/* - *//** - * 详情 - *//* - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入spChangeDetail") - public R detail(HzimsSpChangeDetailEntity spChangeDetail) { - HzimsSpChangeDetailEntity detail = spChangeDetailService.getOne(Condition.getQueryWrapper(spChangeDetail)); - return R.data(detail); - } - - *//** - * 分页 代码自定义代号 - *//* - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spChangeDetail") - public R> list(HzimsSpChangeDetailEntity spChangeDetail, Query query) { - IPage pages = spChangeDetailService.page(Condition.getPage(query), Condition.getQueryWrapper(spChangeDetail)); - return R.data(pages); - } - - *//** - * 新增 代码自定义代号 - *//* - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "新增", notes = "传入spChangeDetail") - public R save(@Valid @RequestBody HzimsSpChangeDetailEntity spChangeDetail) { - return R.status(spChangeDetailService.save(spChangeDetail)); - } - - *//** - * 修改 代码自定义代号 - *//* - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入spChangeDetail") - public R update(@Valid @RequestBody HzimsSpChangeDetailEntity spChangeDetail) { - return R.status(spChangeDetailService.updateById(spChangeDetail)); - } - - *//** - * 新增或修改 代码自定义代号 - *//* - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入spChangeDetail") - public R submit(@Valid @RequestBody HzimsSpChangeDetailEntity spChangeDetail) { - return R.status(spChangeDetailService.saveOrUpdate(spChangeDetail)); - } - - - *//** - * 删除 代码自定义代号 - *//* - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spChangeDetailService.deleteLogic(Func.toLongList(ids))); - }*/ - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeRecController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeRecController.java deleted file mode 100644 index 7116021..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpChangeRecController.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSort; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import com.hnac.hzims.spare.service.IHzimsSpChangeRecService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件出入库 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/spare/spChangeRec") -@ApiSort(value = 4) -@Api(value = "备品备件出入库", tags = "备品备件出入库") -public class HzimsSpChangeRecController extends BladeController { - - private final IHzimsSpChangeRecService spChangeRecService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "详情", notes = "传入spChangeRec") - public R detail(HzimsSpChangeRecEntity spChangeRec) { - HzimsSpChangeRecEntity detail = spChangeRecService.getOne(Condition.getQueryWrapper(spChangeRec)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spChangeRec") - public R> list(HzimsSpChangeRecEntity spChangeRec, Query query) { - IPage pages = spChangeRecService.page(Condition.getPage(query), Condition.getQueryWrapper(spChangeRec)); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "新增", notes = "传入spChangeRec") - public R save(@Valid @RequestBody HzimsSpChangeRecEntity spChangeRec) { - return R.status(spChangeRecService.save(spChangeRec)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 11) - @ApiOperation(value = "修改", notes = "传入spChangeRec") - public R update(@Valid @RequestBody HzimsSpChangeRecEntity spChangeRec) { - return R.status(spChangeRecService.updateById(spChangeRec)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "新增或修改", notes = "传入spChangeRec") - public R submit(@Valid @RequestBody HzimsSpChangeRecEntity spChangeRec) { - return R.status(spChangeRecService.saveOrUpdate(spChangeRec)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 12) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spChangeRecService.deleteLogic(Func.toLongList(ids))); - } - - - - /** - * 删除 (物理删除) - */ - @PostMapping("/removeById") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "物理删除", notes = "传入id") - public R removeById(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - return R.status(spChangeRecService.removeById(id)); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpFileController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpFileController.java deleted file mode 100644 index f909dff..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpFileController.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; -import com.hnac.hzims.spare.service.IHzimsSpFileService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件文件表 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/hzims-spare/spFile") -@Api(value = "备品备件文件表", tags = "备品备件文件表") -public class HzimsSpFileController extends BladeController { - - private final IHzimsSpFileService spFileService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入spFile") - public R detail(HzimsSpFileEntity spFile) { - HzimsSpFileEntity detail = spFileService.getOne(Condition.getQueryWrapper(spFile)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spFile") - public R> list(HzimsSpFileEntity spFile, Query query) { - IPage pages = spFileService.page(Condition.getPage(query), Condition.getQueryWrapper(spFile)); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "新增", notes = "传入spFile") - public R save(@Valid @RequestBody HzimsSpFileEntity spFile) { - return R.status(spFileService.save(spFile)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入spFile") - public R update(@Valid @RequestBody HzimsSpFileEntity spFile) { - return R.status(spFileService.updateById(spFile)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入spFile") - public R submit(@Valid @RequestBody HzimsSpFileEntity spFile) { - return R.status(spFileService.saveOrUpdate(spFile)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spFileService.deleteLogic(Func.toLongList(ids))); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpProviderController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpProviderController.java deleted file mode 100644 index e06866e..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpProviderController.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSort; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; -import com.hnac.hzims.spare.service.IHzimsSpProviderService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件供应商 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/spare/spProvider") -@ApiSort(value = 3) -@Api(value = "备品备件供应商", tags = "备品备件供应商") -public class HzimsSpProviderController extends BladeController { - - private final IHzimsSpProviderService spProviderService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "详情", notes = "传入spProvider") - public R detail(HzimsSpProviderEntity spProvider) { - HzimsSpProviderEntity detail = spProviderService.getOne(Condition.getQueryWrapper(spProvider)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spProvider") - public R> list(HzimsSpProviderEntity spProvider, Query query) { - String name = spProvider.getName(); - String legalPerson = spProvider.getLegalPerson(); - spProvider.setName(null); - spProvider.setLegalPerson(null); - QueryWrapper queryWrapper = Condition.getQueryWrapper(spProvider); - if(StringUtils.isNotBlank(name)){ - queryWrapper.like("NAME",name); - } - if(StringUtils.isNotBlank(legalPerson)){ - queryWrapper.like("LEGAL_PERSON",legalPerson); - } - - IPage pages = spProviderService.page(Condition.getPage(query), queryWrapper); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "新增", notes = "传入spProvider") - public R save(@Valid @RequestBody HzimsSpProviderEntity spProvider) { - return R.status(spProviderService.save(spProvider)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 11) - @ApiOperation(value = "修改", notes = "传入spProvider") - public R update(@Valid @RequestBody HzimsSpProviderEntity spProvider) { - return R.status(spProviderService.updateById(spProvider)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "新增或修改", notes = "传入spProvider") - public R submit(@Valid @RequestBody HzimsSpProviderEntity spProvider) { - return R.status(spProviderService.saveOrUpdate(spProvider)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 12) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spProviderService.deleteLogic(Func.toLongList(ids))); - } - - - - /** - * 删除 (物理删除) - */ - @PostMapping("/removeById") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "物理删除", notes = "传入id") - public R removeById(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - return R.status(spProviderService.removeById(id)); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpRelevanceFileController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpRelevanceFileController.java deleted file mode 100644 index 6bdb69a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpRelevanceFileController.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; -import com.hnac.hzims.spare.service.IHzimsSpRelevanceFileService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件文件关联 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/hzims-spare/spRelevanceFile") -@Api(value = "备品备件文件关联", tags = "备品备件文件关联") -public class HzimsSpRelevanceFileController extends BladeController { - - private final IHzimsSpRelevanceFileService spRelevanceFileService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入spRelevanceFile") - public R detail(HzimsSpRelevanceFileEntity spRelevanceFile) { - HzimsSpRelevanceFileEntity detail = spRelevanceFileService.getOne(Condition.getQueryWrapper(spRelevanceFile)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spRelevanceFile") - public R> list(HzimsSpRelevanceFileEntity spRelevanceFile, Query query) { - IPage pages = spRelevanceFileService.page(Condition.getPage(query), Condition.getQueryWrapper(spRelevanceFile)); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "新增", notes = "传入spRelevanceFile") - public R save(@Valid @RequestBody HzimsSpRelevanceFileEntity spRelevanceFile) { - return R.status(spRelevanceFileService.save(spRelevanceFile)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入spRelevanceFile") - public R update(@Valid @RequestBody HzimsSpRelevanceFileEntity spRelevanceFile) { - return R.status(spRelevanceFileService.updateById(spRelevanceFile)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入spRelevanceFile") - public R submit(@Valid @RequestBody HzimsSpRelevanceFileEntity spRelevanceFile) { - return R.status(spRelevanceFileService.saveOrUpdate(spRelevanceFile)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spRelevanceFileService.deleteLogic(Func.toLongList(ids))); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpTypeController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpTypeController.java deleted file mode 100644 index e56573e..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpTypeController.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSort; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import com.hnac.hzims.spare.service.IHzimsSpTypeService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - - -/** - * 备品备件类型 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/spare/spType") -@ApiSort(value = 1) -@Api(value = "备品备件类型", tags = "备品备件类型") -public class HzimsSpTypeController extends BladeController { - - @Autowired - private IHzimsSpTypeService spTypeService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "详情", notes = "传入spType") - public R detail(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - HzimsSpTypeEntity spType = new HzimsSpTypeEntity(); - spType.setId(id); - HzimsSpTypeEntity detail = spTypeService.getOne(Condition.getQueryWrapper(spType)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spType") - public R> list(HzimsSpTypeEntity spType, Query query) { - /*QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.like("NAME",spType.getName()); - IPage pages = spTypeService.page(Condition.getPage(query), queryWrapper);*/ - String name = spType.getName(); - spType.setName(null); - QueryWrapper queryWrapper = Condition.getQueryWrapper(spType); - if(StringUtils.isNotBlank(name)){ - queryWrapper.like("NAME",name); - } - - IPage pages = spTypeService.page(Condition.getPage(query), queryWrapper); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "新增", notes = "传入spType") - public R save(@Valid @RequestBody HzimsSpTypeEntity spType) { - return R.status(spTypeService.save(spType)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 11) - @ApiOperation(value = "修改", notes = "传入spType") - public R update(@Valid @RequestBody HzimsSpTypeEntity spType) { - return R.status(spTypeService.updateById(spType)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "新增或修改", notes = "传入spType") - public R submit(@Valid @RequestBody HzimsSpTypeEntity spType) { - return R.status(spTypeService.saveOrUpdate(spType)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 12) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spTypeService.deleteLogic(Func.toLongList(ids))); - } - - - - /** - * 删除 (物理删除) - */ - @PostMapping("/removeById") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "物理删除", notes = "传入id") - public R removeById(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - return R.status(spTypeService.removeById(id)); - } - - /** - * 获取所有备品备件树 - */ - @ApiOperation(value = "获取所有备品备件树", httpMethod = "GET") - @GetMapping("/getAllSpTypeTree") - @ApiOperationSupport(order = 5) - @ResponseBody - public R getEquipmentTypeTree(){ - return R.data(spTypeService.getSpTypeTree()); - } - - /** - * 获取所有备品类型(不分页) - */ - @ApiOperation(value = "获取所有备品备件(不分页)", httpMethod = "GET") - @GetMapping("/getList") - @ApiOperationSupport(order = 6) - @ResponseBody - public R> getList(){ - List list = spTypeService.getList(); - return R.data(list); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWareRelatedController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWareRelatedController.java deleted file mode 100644 index 3c6e9e1..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWareRelatedController.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.hnac.hzims.spare.service.IHzimsSpWareRelatedService; -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * 备品备件仓库备件关联表 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/hzims-spare/spWareRelated") -@Api(value = "备品备件仓库备件关联表", tags = "备品备件仓库备件关联表") -public class HzimsSpWareRelatedController extends BladeController { - - private final IHzimsSpWareRelatedService spWareRelatedService; -/* - *//** - * 详情 - *//* - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入spWareRelated") - public R detail(HzimsSpWareRelatedEntity spWareRelated) { - HzimsSpWareRelatedEntity detail = spWareRelatedService.getOne(Condition.getQueryWrapper(spWareRelated)); - return R.data(detail); - } - - *//** - * 分页 代码自定义代号 - *//* - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spWareRelated") - public R> list(HzimsSpWareRelatedEntity spWareRelated, Query query) { - IPage pages = spWareRelatedService.page(Condition.getPage(query), Condition.getQueryWrapper(spWareRelated)); - return R.data(pages); - } - - *//** - * 新增 代码自定义代号 - *//* - @PostMapping("/save") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "新增", notes = "传入spWareRelated") - public R save(@Valid @RequestBody HzimsSpWareRelatedEntity spWareRelated) { - return R.status(spWareRelatedService.save(spWareRelated)); - } - - *//** - * 修改 代码自定义代号 - *//* - @PostMapping("/update") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "修改", notes = "传入spWareRelated") - public R update(@Valid @RequestBody HzimsSpWareRelatedEntity spWareRelated) { - return R.status(spWareRelatedService.updateById(spWareRelated)); - } - - *//** - * 新增或修改 代码自定义代号 - *//* - @PostMapping("/submit") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "新增或修改", notes = "传入spWareRelated") - public R submit(@Valid @RequestBody HzimsSpWareRelatedEntity spWareRelated) { - return R.status(spWareRelatedService.saveOrUpdate(spWareRelated)); - } - - - *//** - * 删除 代码自定义代号 - *//* - @PostMapping("/remove") - @ApiOperationSupport(order = 7) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spWareRelatedService.deleteLogic(Func.toLongList(ids))); - }*/ - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWarehouseController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWarehouseController.java deleted file mode 100644 index d5632e2..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSpWarehouseController.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSort; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; -import com.hnac.hzims.spare.service.IHzimsSpWarehouseService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件仓库 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/spare/spWarehouse") -@ApiSort(value = 4) -@Api(value = "备品备件仓库", tags = "备品备件仓库") -public class HzimsSpWarehouseController extends BladeController { - - private final IHzimsSpWarehouseService spWarehouseService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "详情", notes = "传入spWarehouse") - public R detail(HzimsSpWarehouseEntity spWarehouse) { - HzimsSpWarehouseEntity detail = spWarehouseService.getOne(Condition.getQueryWrapper(spWarehouse)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spWarehouse") - public R> list(HzimsSpWarehouseEntity spWarehouse, Query query) { - String name = spWarehouse.getName(); - spWarehouse.setName(null); - QueryWrapper queryWrapper = Condition.getQueryWrapper(spWarehouse); - if(StringUtils.isNotBlank(name)){ - queryWrapper.like("NAME",name); - } - - IPage pages = spWarehouseService.page(Condition.getPage(query), queryWrapper); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "新增", notes = "传入spWarehouse") - public R save(@Valid @RequestBody HzimsSpWarehouseEntity spWarehouse) { - return R.status(spWarehouseService.save(spWarehouse)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 11) - @ApiOperation(value = "修改", notes = "传入spWarehouse") - public R update(@Valid @RequestBody HzimsSpWarehouseEntity spWarehouse) { - return R.status(spWarehouseService.updateById(spWarehouse)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "新增或修改", notes = "传入spWarehouse") - public R submit(@Valid @RequestBody HzimsSpWarehouseEntity spWarehouse) { - return R.status(spWarehouseService.saveOrUpdate(spWarehouse)); - } - - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 12) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(spWarehouseService.deleteLogic(Func.toLongList(ids))); - } - - - - /** - * 删除 (物理删除) - */ - @PostMapping("/removeById") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "物理删除", notes = "传入id") - public R removeById(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - return R.status(spWarehouseService.removeById(id)); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSparePartsController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSparePartsController.java deleted file mode 100644 index 28e6bd0..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/HzimsSparePartsController.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSort; -import com.hnac.hzims.spare.dto.HzimsSpareCountDTO; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import com.hnac.hzims.spare.service.IHzimsSparePartsService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - - -/** - * 备品备件 控制器 - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/spare/spareParts") -@ApiSort(value = 2) -@Api(value = "备品备件", tags = "备品备件") -public class HzimsSparePartsController extends BladeController { - - private final IHzimsSparePartsService sparePartsService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "详情", notes = "传入spareParts") - public R detail(HzimsSparePartsEntity spareParts) { - HzimsSparePartsEntity detail = sparePartsService.getOne(Condition.getQueryWrapper(spareParts)); - return R.data(detail); - } - - /** - * 分页 代码自定义代号 - */ - @GetMapping("/list") - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入spareParts") - public R> list(HzimsSparePartsEntity spareParts, Query query) { - IPage pages = sparePartsService.page(Condition.getPage(query), Condition.getQueryWrapper(spareParts)); - return R.data(pages); - } - - /** - * 新增 代码自定义代号 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "新增", notes = "传入spareParts") - public R save(@Valid @RequestBody HzimsSparePartsEntity spareParts) { - return R.status(sparePartsService.save(spareParts)); - } - - /** - * 修改 代码自定义代号 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 11) - @ApiOperation(value = "修改", notes = "传入spareParts") - public R update(@Valid @RequestBody HzimsSparePartsEntity spareParts) { - return R.status(sparePartsService.updateById(spareParts)); - } - - /** - * 新增或修改 代码自定义代号 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "新增或修改", notes = "传入spareParts") - public R submit(@Valid @RequestBody HzimsSparePartsEntity spareParts) { - return R.status(sparePartsService.saveOrUpdate(spareParts)); - } - - /** - * 删除 代码自定义代号 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 12) - @ApiOperation(value = "逻辑删除", notes = "传入ids") - public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(sparePartsService.deleteLogic(Func.toLongList(ids))); - } - - - - /** - * 删除 (物理删除) - */ - @PostMapping("/removeById") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "物理删除", notes = "传入id") - public R removeById(@ApiParam(value = "主键", required = true) @RequestParam Long id) { - return R.status(sparePartsService.removeById(id)); - } - - /** - * 查询备件统计信息 - */ - @GetMapping("/selectSpareParts") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "查询备件统计信息", notes = "传入spareParts") - public R> selectSpareParts(Query query,HzimsSparePartsEntity spareParts,String date) { - R> pages = sparePartsService.pageDTO(spareParts, query,date); - //List list = sparePartsService.selectSpareParts(typeId,date); - return pages; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/NoticeController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/NoticeController.java deleted file mode 100644 index b4f39e3..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/NoticeController.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.spare.entity.Notice; -import com.hnac.hzims.spare.service.INoticeService; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import io.swagger.annotations.*; -import lombok.AllArgsConstructor; -import com.hnac.hzims.common.cache.CacheNames; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; - -import java.util.Map; - -/** - * 控制器 - * - * @author Chill - */ -@RestController -@RequestMapping("notice") -@AllArgsConstructor -@Api(value = "用户博客", tags = "博客接口") -public class NoticeController extends BladeController implements CacheNames { - - private final INoticeService noticeService; - - /** - * 详情 - */ - @GetMapping("/detail") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入notice") - public R detail(Notice notice) { - Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice)); - return R.data(detail); - } - - /** - * 分页 - */ - @GetMapping("/list") - @ApiImplicitParams({ - @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"), - @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string") - }) - @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入notice") - public R> list(@ApiIgnore @RequestParam Map notice, Query query) { - IPage pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class)); - return R.data(pages); - } - - /** - * 新增 - */ - @PostMapping("/save") - @ApiOperationSupport(order = 3) - @ApiOperation(value = "新增", notes = "传入notice") - public R save(@RequestBody Notice notice) { - return R.status(noticeService.save(notice)); - } - - /** - * 修改 - */ - @PostMapping("/update") - @ApiOperationSupport(order = 4) - @ApiOperation(value = "修改", notes = "传入notice") - public R update(@RequestBody Notice notice) { - return R.status(noticeService.updateById(notice)); - } - - /** - * 新增或修改 - */ - @PostMapping("/submit") - @ApiOperationSupport(order = 5) - @ApiOperation(value = "新增或修改", notes = "传入notice") - public R submit(@RequestBody Notice notice) { - return R.status(noticeService.saveOrUpdate(notice)); - } - - /** - * 删除 - */ - @PostMapping("/remove") - @ApiOperationSupport(order = 6) - @ApiOperation(value = "逻辑删除", notes = "传入notice") - public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { - boolean temp = noticeService.deleteLogic(Func.toLongList(ids)); - return R.status(temp); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/UploadController.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/UploadController.java deleted file mode 100644 index 270098f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/controller/UploadController.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.spare.controller; - -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import lombok.SneakyThrows; -import org.springblade.core.oss.minio.MinioTemplate; -import org.springblade.core.oss.model.BladeFile; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * UploadController - * - * @author Chill - */ -@RestController -@AllArgsConstructor -@RequestMapping("/notice/upload") -@Api(value = "对象存储接口", tags = "oss上传测试") -public class UploadController { - - private final MinioTemplate minioTemplate; - - /** - * minio上传demo - * - * @param file 上传文件 - * @return String - */ - @SneakyThrows - @PostMapping("put-object") - public R putMinioObject(@RequestParam MultipartFile file) { - BladeFile bladeFile = minioTemplate.putFile(file); - return R.data(bladeFile); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeDetailDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeDetailDTO.java deleted file mode 100644 index 4b47375..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeDetailDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; - -/** - * 备品备件出入库详情 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpChangeDetailDTO extends HzimsSpChangeDetailEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeRecDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeRecDTO.java deleted file mode 100644 index f377c6b..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpChangeRecDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -/** - * 备品备件出入库 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpChangeRecDTO extends HzimsSpChangeRecEntity { - - private static final long serialVersionUID = 1L; - - /** - * 变更详情(要变更的备件名称、数量、单价等) - */ - @ApiModelProperty(value = "变更详情(要变更的备件名称、数量、单价等)") - private List details; - - @ApiModelProperty(value = "审核通过标识") - private boolean checkFlag; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpFileDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpFileDTO.java deleted file mode 100644 index ed1a6b8..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpFileDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; - -/** - * 备品备件文件表 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpFileDTO extends HzimsSpFileEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpProviderDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpProviderDTO.java deleted file mode 100644 index 8067fea..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpProviderDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; - -/** - * 备品备件供应商 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpProviderDTO extends HzimsSpProviderEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpRelevanceFileDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpRelevanceFileDTO.java deleted file mode 100644 index 4b49132..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpRelevanceFileDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; - -/** - * 备品备件文件关联 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpRelevanceFileDTO extends HzimsSpRelevanceFileEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpTypeDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpTypeDTO.java deleted file mode 100644 index 775a2e0..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpTypeDTO.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import com.hnac.hzims.spare.utils.TreeObject; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.util.List; - -/** - * 备品备件类型 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpTypeDTO extends HzimsSpTypeEntity implements Serializable, TreeObject { - - private static final long serialVersionUID = 1L; - - private List children; - - /*@Override - public Long getId(){ - return super.getId(); - } - - @Override - public void setId(Long id) { - super.setId(id); - } - - @Override - public Long getParentId() { - return super.getParentId(); - } - - @Override - public void setParentId(Long parentId) { - super.setParentId(parentId); - } - - @Override - public String getName() { - return super.getName(); - } - - @Override - public void setName(String name) { - super.setName(name); - }*/ - - public List getChildren() { - return this.children; - } - - public void setChildren(List children) { - this.children = children; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWareRelatedDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWareRelatedDTO.java deleted file mode 100644 index 49d7c02..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWareRelatedDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; - -/** - * 备品备件仓库备件关联表 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpWareRelatedDTO extends HzimsSpWareRelatedEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWarehouseDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWarehouseDTO.java deleted file mode 100644 index 04926b8..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpWarehouseDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; - -/** - * 备品备件仓库 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpWarehouseDTO extends HzimsSpWarehouseEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpareCountDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpareCountDTO.java deleted file mode 100644 index 746393f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSpareCountDTO.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 设备统计DTO - */ -@Data -public class HzimsSpareCountDTO implements Serializable { - private static final long serialVersionUID = -5172898121198875607L; - - private Long id; - /** - * 备件编号 - */ - private String code; - /** - * 备件名称 - */ - private String name; - /** - * 规格型号 - */ - private String specification; - /** - * 类型ID - */ - private Long typeId; - /** - * 类型名称 - */ - private String typeName; - /** - * 单位 - */ - private String unit; - - /** - * 仓库名称 - */ - private String warehouseName; - /** - * 入库数量 - */ - private Long inQuantity; - /** - * 出库数量 - */ - private Long outQuantity; - /** - * 入库总价 - */ - private BigDecimal inPrice; - /** - * 出库总价 - */ - private BigDecimal outPrice; -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSparePartsDTO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSparePartsDTO.java deleted file mode 100644 index aa1cf78..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/dto/HzimsSparePartsDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; - -/** - * 备品备件 模型DTO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSparePartsDTO extends HzimsSparePartsEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeDetailEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeDetailEntity.java deleted file mode 100644 index e09275d..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeDetailEntity.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.math.BigDecimal; - - -/** - * 备品备件出入库详情 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_change_detail") -@ApiModel(value = "HzimsSpChangeDetail对象", description = "备品备件出入库详情") -public class HzimsSpChangeDetailEntity { - - private static final long serialVersionUID = 1L; - - /** - * 变更记录ID - */ - @ApiModelProperty(value = "变更记录ID") - private Long changeId; - /** - * 仓库ID - */ - @ApiModelProperty(value = "仓库ID") - private Long warehouseId; - /** - * 供应商 - */ - @ApiModelProperty(value = "供应商") - private Long provider; - /** - * 备品备件ID - */ - @ApiModelProperty(value = "备品备件ID") - private Long spId; - /** - * 备件编号 - */ - @ApiModelProperty(value = "备件编号") - private String code; - /** - * 备件名称 - */ - @ApiModelProperty(value = "备件名称") - private String name; - /** - * 规格型号 - */ - @ApiModelProperty(value = "规格型号") - private String specification; - /** - * 类型ID - */ - @ApiModelProperty(value = "类型ID") - private Long typeId; - /** - * 数量 - */ - @ApiModelProperty(value = "数量") - private Long quantity; - /** - * 单价 - */ - @ApiModelProperty(value = "单价") - private BigDecimal price; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - /** - * 最低储备量 - */ - @ApiModelProperty(value = "最低储备量") - private Long minStock; - /** - * 最高储备量 - */ - @ApiModelProperty(value = "最高储备量") - private Long maxStock; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeRecEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeRecEntity.java deleted file mode 100644 index 55f143b..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpChangeRecEntity.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import org.springblade.core.mp.base.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; -import java.time.LocalDateTime; - - -/** - * 备品备件出入库 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_change_rec") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpChangeRec对象", description = "备品备件出入库") -public class HzimsSpChangeRecEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 流程实例ID - */ - @ApiModelProperty(value = "流程实例ID") - private String flowId; - /** - * 编号 - */ - @ApiModelProperty(value = "编号") - private String code; - /** - * 变更类型(1采购,2入库,3出库...) - */ - @ApiModelProperty(value = "变更类型(1采购,2入库,3出库...)") - private Integer changeType; - /** - * 变更时间 - */ - @ApiModelProperty(value = "变更时间") - private String changeTime; - /** - * 办理意见 - */ - @ApiModelProperty(value = "办理意见") - private Long handleOpinions; - /** - * 相关单据 - */ - @ApiModelProperty(value = "相关单据") - private String relatedCode; - /** - * 备注(用途) - */ - @ApiModelProperty(value = "备注(用途)") - private String remark; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpFileEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpFileEntity.java deleted file mode 100644 index 990e96a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpFileEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import org.springblade.core.mp.base.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; -import java.time.LocalDateTime; - - -/** - * 备品备件文件表 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_file") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpFile对象", description = "备品备件文件表") -public class HzimsSpFileEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 文件类型 1:图片类型 2:视频类型 3:其他 - */ - @ApiModelProperty(value = "文件类型 1:图片类型 2:视频类型 3:其他") - private String type; - /** - * 文件名称 - */ - @ApiModelProperty(value = "文件名称") - private String name; - /** - * 文件大小 - */ - @ApiModelProperty(value = "文件大小") - private Double size; - /** - * 文件工作空间 - */ - @ApiModelProperty(value = "文件工作空间") - private String workspace; - /** - * 文件源文件 - */ - @ApiModelProperty(value = "文件源文件") - private String fileSource; - /** - * 文件缩略图 - */ - @ApiModelProperty(value = "文件缩略图") - private String fileThumbnail; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpProviderEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpProviderEntity.java deleted file mode 100644 index 17ad25a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpProviderEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import org.springblade.core.mp.base.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; -import java.time.LocalDateTime; - - -/** - * 备品备件供应商 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_provider") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpProvider对象", description = "备品备件供应商") -public class HzimsSpProviderEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 名称 - */ - @ApiModelProperty(value = "名称") - private String name; - /** - * 名称缩写 - */ - @ApiModelProperty(value = "名称缩写") - private String logogram; - /** - * 业务联系人 - */ - @ApiModelProperty(value = "业务联系人") - private String salesman; - /** - * 法人代表 - */ - @ApiModelProperty(value = "法人代表") - private String legalPerson; - /** - * 电话 - */ - @ApiModelProperty(value = "电话") - private String phone; - /** - * 手机 - */ - @ApiModelProperty(value = "手机") - private String mobilePhone; - /** - * 网址 - */ - @ApiModelProperty(value = "网址") - private String website; - /** - * 地址 - */ - @ApiModelProperty(value = "地址") - private String address; - /** - * 是否合格(0:否,1:是) - */ - @ApiModelProperty(value = "是否合格(0:否,1:是)") - private Integer qualifiedFlag; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpRelevanceFileEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpRelevanceFileEntity.java deleted file mode 100644 index 21ac13d..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpRelevanceFileEntity.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import org.springblade.core.mp.base.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; -import java.time.LocalDateTime; - - -/** - * 备品备件文件关联 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_relevance_file") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpRelevanceFile对象", description = "备品备件文件关联") -public class HzimsSpRelevanceFileEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 业务ID - */ - @ApiModelProperty(value = "业务ID") - private Long businessId; - /** - * 文件ID - */ - @ApiModelProperty(value = "文件ID") - private Long fileId; - /** - * 类型 - */ - @ApiModelProperty(value = "类型") - private String type; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpTypeEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpTypeEntity.java deleted file mode 100644 index 8b1b550..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpTypeEntity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.hnac.hzims.spare.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.mp.base.BaseEntity; - - -/** - * 备品备件类型 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_type") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpType对象", description = "备品备件类型") -public class HzimsSpTypeEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 编码 - */ - @ApiModelProperty(value = "编码") - private String code; - /** - * 名称 - */ - @ApiModelProperty(value = "名称") - private String name; - /** - * 单位 - */ - @ApiModelProperty(value = "单位") - private String unit; - /** - * 所属父级 - */ - @ApiModelProperty(value = "所属父级") - private Long parentId; - /** - * 排序 - */ - @ApiModelProperty(value = "排序") - private Integer sort; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWareRelatedEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWareRelatedEntity.java deleted file mode 100644 index 3b44e35..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWareRelatedEntity.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.math.BigDecimal; - - -/** - * 备品备件仓库备件关联表 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_ware_related") -@ApiModel(value = "HzimsSpWareRelated对象", description = "备品备件仓库备件关联表") -public class HzimsSpWareRelatedEntity { - - private static final long serialVersionUID = 1L; - - /** - * 仓库ID - */ - @ApiModelProperty(value = "仓库ID") - private Long warehouseId; - /** - * 备品备件ID - */ - @ApiModelProperty(value = "备品备件ID") - private Long spId; - /** - * 库存 - */ - @ApiModelProperty(value = "库存") - private Long stock; - /** - * 最新入库单价 - */ - @ApiModelProperty(value = "最新入库单价") - private BigDecimal inPrice; - /** - * 最新出库单价 - */ - @ApiModelProperty(value = "最新出库单价") - private BigDecimal outPrice; - /** - * 出库暂存 - */ - @ApiModelProperty(value = "出库暂存") - private Long outStock; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWarehouseEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWarehouseEntity.java deleted file mode 100644 index e67d65f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSpWarehouseEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.hnac.hzims.spare.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import org.springblade.core.mp.base.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; -import java.time.LocalDateTime; - - -/** - * 备品备件仓库 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_sp_warehouse") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpWarehouse对象", description = "备品备件仓库") -public class HzimsSpWarehouseEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 编码 - */ - @ApiModelProperty(value = "编码") - private String code; - /** - * 名称 - */ - @ApiModelProperty(value = "名称") - private String name; - /** - * 负责人 - */ - @ApiModelProperty(value = "负责人") - private Long manager; - /** - * 地址 - */ - @ApiModelProperty(value = "地址") - private String address; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - /** - * 最大存储量 - */ - @ApiModelProperty(value = "最大存储量") - private Long maxStock; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSparePartsEntity.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSparePartsEntity.java deleted file mode 100644 index f6180da..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/entity/HzimsSparePartsEntity.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.hnac.hzims.spare.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.mp.base.BaseEntity; - -import java.math.BigDecimal; - - -/** - * 备品备件 实体类 - * - * @author Chill - */ -@Data -@TableName("hz_ims_spare_parts") -@EqualsAndHashCode(callSuper = true) -@ApiModel(value = "HzimsSpareParts对象", description = "备品备件") -public class HzimsSparePartsEntity extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 备件编号 - */ - @ApiModelProperty(value = "备件编号") - private String code; - /** - * 备件名称 - */ - @ApiModelProperty(value = "备件名称") - private String name; - /** - * 规格型号 - */ - @ApiModelProperty(value = "规格型号") - private String specification; - /** - * 类型ID - */ - @ApiModelProperty(value = "类型ID") - private Long typeId; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - /** - * 最低储备量 - */ - @ApiModelProperty(value = "最低储备量") - private Long minStock; - /** - * 最高储备量 - */ - @ApiModelProperty(value = "最高储备量") - private Long maxStock; - /** - * 库存 - */ - @ApiModelProperty(value = "库存") - private Long stock; - /** - * 最新入库单价 - */ - @ApiModelProperty(value = "最新入库单价") - private BigDecimal inPrice; - /** - * 最新出库单价 - */ - @ApiModelProperty(value = "最新出库单价") - private BigDecimal outPrice; - /** - * 出库暂存 - */ - @ApiModelProperty(value = "出库暂存") - private Long outStock; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/enumeration/ChangeStatusEnum.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/enumeration/ChangeStatusEnum.java deleted file mode 100644 index 2037403..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/enumeration/ChangeStatusEnum.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.hnac.hzims.spare.enumeration; - -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author Huj - * created in 2020/03/16 9:21 - * @description - **/ -public enum ChangeStatusEnum { - - SUBMIT_PENDING(1, "待提交"), - CHECK_PENDING(2, "待审核"), - REJECT_SUBMIT_PENDING(3, "驳回待提交"), - COMPLETED(4, "已完成"); - - private static final Map DICT = Stream.of(values()) - .collect(Collectors.toMap(ChangeStatusEnum::getCode, t -> t)); - - private final Integer code; - - private final String description; - - private ChangeStatusEnum(Integer code, String description) { - this.code = code; - this.description = description; - } - - /** - * 返回编码对应的枚举实例 - * @param code - * @return - */ - public static Optional getInstance(String code) { - return Optional.ofNullable(DICT.get(Integer.parseInt(code))); - } - - public Integer getCode() { - return code; - } - - public String getDescription() { - return description; - } - - public static ChangeStatusEnum getEnumByCode(Integer code){ - for(ChangeStatusEnum thisEnum : ChangeStatusEnum.values()){ - if(thisEnum.getCode().equals(code)){ - return thisEnum; - } - } - return null; - } - - public static List> getKeyValueList(){ - List> types = new ArrayList(); - ChangeStatusEnum[] enums = values(); - Map thisMap; - for (ChangeStatusEnum thisEnum:enums){ - thisMap = new HashMap<>(); - thisMap.put("value",thisEnum.getCode()); - thisMap.put("name",thisEnum.getDescription()); - types.add(thisMap); - } - return types; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/feign/NoticeClient.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/feign/NoticeClient.java deleted file mode 100644 index 707ccd4..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/feign/NoticeClient.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.feign; - -import com.hnac.hzims.spare.entity.Notice; -import com.hnac.hzims.spare.mapper.NoticeMapper; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; - -import java.util.List; - -/** - * Notice Feign - * - * @author Chill - */ -@ApiIgnore() -@RestController -@AllArgsConstructor -public class NoticeClient implements INoticeClient { - - private final NoticeMapper mapper; - - @Override - @GetMapping(TOP) - public R> top(Integer number) { - return R.data(mapper.topList(number)); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.java deleted file mode 100644 index 7f504e0..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; -import com.hnac.hzinfo.core.annotation.CommonDao; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 备品备件出入库详情 Mapper 接口 - * - * @author Chill - */ -@CommonDao -public interface HzimsSpChangeDetailMapper extends BaseMapper { - /** - * 根据变更ID 物理删除 - * @param changeId - * @return - */ - int deleteByChangeId(@Param("changeId") Long changeId); - - int insertBatch(@Param("records") List records); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.xml deleted file mode 100644 index fcfcf53..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeDetailMapper.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_change_detail - where CHANGE_ID = #{changeId,jdbcType=BIGINT} - - - - insert into hz_ims_sp_change_detail (CHANGE_ID, WAREHOUSE_ID, PROVIDER, SP_ID, CODE, NAME, SPECIFICATION, TYPE_ID, - QUANTITY, PRICE, REMARK, MIN_STOCK, MAX_STOCK - ) - values - - (#{item.changeId,jdbcType=BIGINT}, #{item.warehouseId,jdbcType=BIGINT}, #{item.provider,jdbcType=BIGINT}, - #{item.spId,jdbcType=BIGINT}, #{item.code,jdbcType=VARCHAR},#{item.name,jdbcType=VARCHAR}, - #{item.specification,jdbcType=VARCHAR}, #{item.typeId,jdbcType=BIGINT}, #{item.quantity,jdbcType=BIGINT}, - #{item.price,jdbcType=DECIMAL}, - #{item.remark,jdbcType=VARCHAR}, #{item.minStock,jdbcType=BIGINT}, #{item.maxStock,jdbcType=BIGINT} - ) - - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.java deleted file mode 100644 index 7608daa..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import org.apache.ibatis.annotations.Param; - -/** - * 备品备件出入库 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSpChangeRecMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.xml deleted file mode 100644 index d3d6a99..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpChangeRecMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_change_rec - where ID = #{id,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.java deleted file mode 100644 index bff2ff5..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; -import org.apache.ibatis.annotations.Param; - -/** - * 备品备件文件表 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSpFileMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.xml deleted file mode 100644 index 095aca5..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpFileMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_file - where ID = #{id,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.java deleted file mode 100644 index dbcc229..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; -import org.apache.ibatis.annotations.Param; - -/** - * 备品备件供应商 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSpProviderMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.xml deleted file mode 100644 index 94b4c2c..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpProviderMapper.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_provider - where ID = #{id,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.java deleted file mode 100644 index 13f6c15..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; -import org.apache.ibatis.annotations.Param; - -/** - * 备品备件文件关联 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSpRelevanceFileMapper extends BaseMapper { - /** - * 物理删除 - * @param fileId - * @return - */ - int deleteByFileId(@Param("fileId") Long fileId); - int deleteByBusinessId(@Param("businessId") Long businessId); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.xml deleted file mode 100644 index b0e05c10..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpRelevanceFileMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - delete from hz_ims_sp_relevance_file - where FILE_ID = #{fileId,jdbcType=BIGINT} - - - - delete from hz_ims_sp_relevance_file - where BUSINESS_ID = #{businessId,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.java deleted file mode 100644 index af3125c..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.dto.HzimsSpTypeDTO; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import com.hnac.hzinfo.core.annotation.CommonDao; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 备品备件类型 Mapper 接口 - * - * @author Chill - */ -@CommonDao -public interface HzimsSpTypeMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - - List selectAllSpTypeList() ; - - /** - * 获取所有备件类型(不分页) - * @return - */ - List getList(); -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.xml deleted file mode 100644 index abc1d7d..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpTypeMapper.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_type - where ID = #{id,jdbcType=BIGINT} - - - - - - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.java deleted file mode 100644 index 2368c05..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; -import com.hnac.hzinfo.core.annotation.CommonDao; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 备品备件仓库备件关联表 Mapper 接口 - * - * @author Chill - */ -@CommonDao -public interface HzimsSpWareRelatedMapper extends BaseMapper { - /** - * 物理删除 - * @param warehouseId - * @return - */ - int deleteByWarehouseId(@Param("warehouseId") Long warehouseId); - - int insertBatch(@Param("records") List records); - - /** - * 选择性更新 入库(注:库存的更新SQL中是累加) - * @param record - * @return - */ - int updateSelectiveInStock(HzimsSpWareRelatedEntity record); - /** - * 选择性更新 出库(注:出库暂存的更新SQL中是相减) - * @param record - * @return - */ - int updateSelectiveOutStock(HzimsSpWareRelatedEntity record); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.xml deleted file mode 100644 index 66b6cfc..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWareRelatedMapper.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - delete from hz_ims_sp_ware_related - where WAREHOUSE_ID = #{warehouseId,jdbcType=BIGINT} - - - - insert into hz_ims_sp_ware_related (WAREHOUSE_ID, SP_ID, STOCK, IN_PRICE, OUT_PRICE, OUT_STOCK - ) - values - - (#{item.warehouseId,jdbcType=BIGINT}, #{item.spId,jdbcType=BIGINT}, #{item.stock,jdbcType=BIGINT}, - #{item.inPrice,jdbcType=DECIMAL}, #{item.outPrice,jdbcType=DECIMAL},#{item.outStock,jdbcType=BIGINT} - ) - - - - - update hz_ims_sp_ware_related - - - STOCK = STOCK + #{stock,jdbcType=BIGINT}, - - - IN_PRICE = #{inPrice,jdbcType=DECIMAL}, - - - where WAREHOUSE_ID = #{warehouseId,jdbcType=BIGINT} - and SP_ID = #{spId,jdbcType=BIGINT} - - - - update hz_ims_sp_ware_related - - - OUT_PRICE = #{outPrice,jdbcType=DECIMAL}, - - - OUT_STOCK = OUT_STOCK - #{outStock,jdbcType=BIGINT}, - - - where WAREHOUSE_ID = #{warehouseId,jdbcType=BIGINT} - and SP_ID = #{spId,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.java deleted file mode 100644 index 4b2b386..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; -import org.apache.ibatis.annotations.Param; - -/** - * 备品备件仓库 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSpWarehouseMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.xml deleted file mode 100644 index 02f48c0..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSpWarehouseMapper.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_sp_warehouse - where ID = #{id,jdbcType=BIGINT} - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.java deleted file mode 100644 index 8bc90ca..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.spare.dto.HzimsSpareCountDTO; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Map; - -/** - * 备品备件 Mapper 接口 - * - * @author Chill - */ -public interface HzimsSparePartsMapper extends BaseMapper { - /** - * 物理删除 - * @param id - * @return - */ - int deleteByPrimaryKey(@Param("id") Long id); - - /** - * 查询备件统计基本信息 - * @param params - * @return - */ - List selectSparePartsBasic(Map params); - - /** - * 查询备件统计出入库数量和价格信息 - * @param params - * @return - */ - List selectSparePartsCount(Map params); -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.xml deleted file mode 100644 index deb33aa..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/HzimsSparePartsMapper.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from hz_ims_spare_parts - where ID = #{id,jdbcType=BIGINT} - - - - - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.java deleted file mode 100644 index 71f93e9..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.spare.entity.Notice; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * Mapper 接口 - * - * @author Chill - */ -public interface NoticeMapper extends BaseMapper { - - /** - * 前N条数据 - * @param number - * @return - */ - List topList(Integer number); - - /** - * 自定义分页 - * @param page - * @param notice - * @return - */ - List selectNoticePage(IPage page, Notice notice); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.xml b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.xml deleted file mode 100644 index 58d53f3..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/mapper/NoticeMapper.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - select id, - create_user AS createUser, - create_time AS createTime, - update_user AS updateUser, - update_time AS updateTime, - status, - is_deleted AS isDeleted, - title, content - - - - - - - diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/props/DemoProperties.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/props/DemoProperties.java deleted file mode 100644 index b5af15f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/props/DemoProperties.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.props; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * DemoProperties - * - * @author Chill - */ -@Data -@ConfigurationProperties(prefix = "demo") -public class DemoProperties { - /** - * 名称 - */ - private String name; -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IDynamicService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IDynamicService.java deleted file mode 100644 index cf74947..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IDynamicService.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.service; - -import com.hnac.hzims.spare.entity.Notice; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * 服务类 - * - * @author Chill - */ -public interface IDynamicService extends BaseService { - - /** - * master数据源的列表 - * - * @return - */ - List masterList(); - - /** - * slave数据源的列表 - * - * @return - */ - List slaveList(); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeDetailService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeDetailService.java deleted file mode 100644 index c74fa8a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeDetailService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.spare.service; - -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; - -import java.util.List; - -/** - * 备品备件出入库详情 服务类 - * - * @author Chill - */ -public interface IHzimsSpChangeDetailService { - - int saveBatch(List entitys) ; - - /** - * 物理删除 - * @param changeId - * @return - */ - boolean removeByChangeId(Long changeId); -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeRecService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeRecService.java deleted file mode 100644 index e749905..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpChangeRecService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hnac.hzims.spare.service; - -import com.hnac.hzims.spare.dto.HzimsSpChangeRecDTO; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * 备品备件出入库 服务类 - * - * @author Chill - */ -public interface IHzimsSpChangeRecService extends BaseService { - - /** - * 物理删除 - * @param id - * @return - */ - boolean removeById(Long id); - - /** - * 变更暂存 - * @param dto - * @return - */ - boolean saveOrUpdate(HzimsSpChangeRecDTO dto); - - /** - * 变更提交审核 - * @param dto - * @return - */ - boolean saveAndSubmit(HzimsSpChangeRecDTO dto); - - /** - * 变更 审核 - * @param dto - * @return - */ - boolean doCheck(HzimsSpChangeRecDTO dto); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpFileService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpFileService.java deleted file mode 100644 index 8043a22..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpFileService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.spare.service; - -import org.springblade.core.mp.base.BaseService; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; - -/** - * 备品备件文件表 服务类 - * - * @author Chill - */ -public interface IHzimsSpFileService extends BaseService { - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpProviderService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpProviderService.java deleted file mode 100644 index 8685216..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpProviderService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.service; - -import org.springblade.core.mp.base.BaseService; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; - -/** - * 备品备件供应商 服务类 - * - * @author Chill - */ -public interface IHzimsSpProviderService extends BaseService { - - /** - * 物理删除 - * @param id - * @return - */ - boolean removeById(Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpRelevanceFileService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpRelevanceFileService.java deleted file mode 100644 index d5b1300..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpRelevanceFileService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.spare.service; - -import org.springblade.core.mp.base.BaseService; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; - -/** - * 备品备件文件关联 服务类 - * - * @author Chill - */ -public interface IHzimsSpRelevanceFileService extends BaseService { - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpTypeService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpTypeService.java deleted file mode 100644 index 7a4322f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpTypeService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.spare.service; - -import com.hnac.hzims.spare.dto.HzimsSpTypeDTO; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * 备品备件类型 服务类 - * - * @author Chill - */ -public interface IHzimsSpTypeService extends BaseService { - - /** - * 重写新增或者修改接口,增加code为空,设置编码 - * @param entity - * @return - */ - boolean saveOrUpdate(HzimsSpTypeEntity entity); - - /** - * 物理删除 - * @param id - * @return - */ - boolean removeById(Long id); - - /** - * 获取类型树 - * @return - */ - List getSpTypeTree() ; - - /** - * 查询所有备件类型(不分页) - * @return - */ - List getList(); -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWareRelatedService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWareRelatedService.java deleted file mode 100644 index be58788..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWareRelatedService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.hnac.hzims.spare.service; - -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; - -import java.util.List; - -/** - * 备品备件仓库备件关联表 服务类 - * - * @author Chill - */ -public interface IHzimsSpWareRelatedService { - - int saveBatch(List entitys) ; - - /** - * 物理删除 - * @param warehouseId - * @return - */ - boolean deleteByWarehouseId(Long warehouseId); - - /** - * 选择性更新 入库(注:库存的更新SQL中是累加) - * @param record - * @return - */ - int updateSelectiveInStock(HzimsSpWareRelatedEntity record); - /** - * 选择性更新 出库(注:出库暂存的更新SQL中是相减) - * @param record - * @return - */ - int updateSelectiveOutStock(HzimsSpWareRelatedEntity record); -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWarehouseService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWarehouseService.java deleted file mode 100644 index 79b56f1..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSpWarehouseService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.spare.service; - -import org.springblade.core.mp.base.BaseService; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; - -/** - * 备品备件仓库 服务类 - * - * @author Chill - */ -public interface IHzimsSpWarehouseService extends BaseService { - - /** - * 物理删除 - * @param id - * @return - */ - boolean removeById(Long id); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSparePartsService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSparePartsService.java deleted file mode 100644 index 7e9ba59..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/IHzimsSparePartsService.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hnac.hzims.spare.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.spare.dto.HzimsSpareCountDTO; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import org.springblade.core.mp.base.BaseService; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; - -import java.util.List; - -/** - * 备品备件 服务类 - * - * @author Chill - */ -public interface IHzimsSparePartsService extends BaseService { - - /** - * 重写新增或者修改接口,增加code为空,设置编码 - * @param entity - * @return - */ - boolean saveOrUpdate(HzimsSparePartsEntity entity); - - /** - * 物理删除 - * @param id - * @return - */ - boolean removeById(Long id); - - - /** - * 查询备件统计信息分页 - * @param sparePartsEntity - * @param query - * @return - */ - R> pageDTO(HzimsSparePartsEntity sparePartsEntity, Query query,String date); - - /** - * 查询备件统计信息 - * @param - * @return - */ - List selectSpareParts(Long typeId,String date); - - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/INoticeService.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/INoticeService.java deleted file mode 100644 index 34023fa..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/INoticeService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.spare.entity.Notice; -import org.springblade.core.mp.base.BaseService; - -/** - * 服务类 - * - * @author Chill - */ -public interface INoticeService extends BaseService { - - /** - * 自定义分页 - * @param page - * @param notice - * @return - */ - IPage selectNoticePage(IPage page, Notice notice); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/DynamicServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/DynamicServiceImpl.java deleted file mode 100644 index a49af22..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/DynamicServiceImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.spare.entity.Notice; -import com.hnac.hzims.spare.mapper.NoticeMapper; -import com.hnac.hzims.spare.service.IDynamicService; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * DynamicServiceImpl - * - * @author Chill - */ -@Service -public class DynamicServiceImpl extends BaseServiceImpl implements IDynamicService { - - @Override - public List masterList() { - return this.list(); - } - - @Override - @DS("slave") - public List slaveList() { - return this.list(); - } -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeDetailServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeDetailServiceImpl.java deleted file mode 100644 index c78a2d8..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeDetailServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; -import com.hnac.hzims.spare.mapper.HzimsSpChangeDetailMapper; -import com.hnac.hzims.spare.service.IHzimsSpChangeDetailService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 备品备件出入库详情 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpChangeDetailServiceImpl implements IHzimsSpChangeDetailService { - - private HzimsSpChangeDetailMapper detailMapper; - - @Override - public int saveBatch(List entitys){ - int result = 0; - - if(entitys == null || entitys.size() == 0){ - return result; - } - result = this.detailMapper.insertBatch(entitys); - return result; - } - - @Override - public boolean removeByChangeId(Long changeId){ - return detailMapper.deleteByChangeId(changeId) > 0; - } -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeRecServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeRecServiceImpl.java deleted file mode 100644 index 7d035a9..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpChangeRecServiceImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.hnac.hzims.spare.dto.HzimsSpChangeRecDTO; -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import com.hnac.hzims.spare.enumeration.ChangeStatusEnum; -import com.hnac.hzims.spare.mapper.HzimsSpChangeRecMapper; -import com.hnac.hzims.spare.service.IHzimsSpChangeDetailService; -import com.hnac.hzims.spare.service.IHzimsSpChangeRecService; -import com.hnac.hzims.spare.service.IHzimsSpWareRelatedService; -import com.hnac.hzims.spare.service.IHzimsSparePartsService; -import com.hnac.hzims.spare.utils.CodeDateRandomUtils; -import com.hnac.hzinfo.common.utils.StringUtils; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * 备品备件出入库 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpChangeRecServiceImpl extends BaseServiceImpl implements IHzimsSpChangeRecService { - private static final String PURC_PREFIX_CODE = "PURC"; - private static final String IN_PREFIX_CODE = "IN"; - private static final String OUT_PREFIX_CODE = "OUT"; - - @Autowired - private IHzimsSpChangeDetailService detailservice; - @Autowired - private IHzimsSparePartsService spService; - @Autowired - private IHzimsSpWareRelatedService wareRelatedService; - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean saveOrUpdate(HzimsSpChangeRecDTO dto){ - boolean result = false; - HzimsSpChangeRecEntity entity = new HzimsSpChangeRecEntity(); - BeanUtils.copyProperties(dto,entity); - - entity.setUpdateTime(new Date()); - // 根据变更类型配置编码前缀 - String prefix = "OTHER"; - switch (entity.getChangeType()){ - case 1: prefix = PURC_PREFIX_CODE;break; - case 2: prefix = IN_PREFIX_CODE;break; - case 3: prefix = OUT_PREFIX_CODE;break; - } - entity.setCode(StringUtils.isNotBlank(entity.getCode())?entity.getCode(): CodeDateRandomUtils.generateCode(prefix)); - entity.setStatus(entity.getStatus()==null? ChangeStatusEnum.SUBMIT_PENDING.getCode() :entity.getStatus()); // 待提交 - - if(dto.getId() != null){ - detailservice.removeByChangeId(dto.getId()); - } - - result = super.saveOrUpdate(entity); - dto.setId(entity.getId()); - - if(dto.getDetails() != null && dto.getDetails().size() > 0){ - dto.getDetails().stream().forEach(item -> item.setChangeId(dto.getId())); - detailservice.saveBatch(dto.getDetails()); - } - return result; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean saveAndSubmit(HzimsSpChangeRecDTO dto){ - boolean result = false; - HzimsSpChangeRecEntity entity = new HzimsSpChangeRecEntity(); - BeanUtils.copyProperties(dto,entity); - - entity.setUpdateTime(new Date()); - entity.setStatus(ChangeStatusEnum.CHECK_PENDING.getCode()); // 待审核 - - if(StringUtils.isBlank(dto.getFlowId())) { // 驳回待提交,已经启动工作流 - // TODO 启动工作流,获取到工作流ID - entity.setFlowId(""); - } - - if(dto.getId()==null){ - // 根据变更类型配置编码前缀 - String prefix = "OTHER"; - switch (entity.getChangeType()){ - case 1: prefix = PURC_PREFIX_CODE;break; - case 2: prefix = IN_PREFIX_CODE;break; - case 3: prefix = OUT_PREFIX_CODE;break; - } - entity.setCode(StringUtils.isNotBlank(entity.getCode())?entity.getCode(): CodeDateRandomUtils.generateCode(prefix)); - - result = super.save(entity); - dto.setId(entity.getId()); - }else { - detailservice.removeByChangeId(dto.getId()); - result = super.updateById(entity); - } - - if(dto.getDetails() != null && dto.getDetails().size() > 0){ - dto.getDetails().stream().forEach(item -> item.setChangeId(dto.getId())); - detailservice.saveBatch(dto.getDetails()); - } - - // TODO 如果是出库,查询库存,并减库存,增加出库暂存 - - - return result; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean doCheck(HzimsSpChangeRecDTO dto){ - HzimsSpChangeRecEntity entity = new HzimsSpChangeRecEntity(); - BeanUtils.copyProperties(dto,entity); - - entity.setUpdateTime(new Date()); - entity.setStatus(dto.isCheckFlag()? ChangeStatusEnum.COMPLETED.getCode() :ChangeStatusEnum.REJECT_SUBMIT_PENDING.getCode()); // 已完成/审核驳回 - - // 各种类型变更完成调用不同的操作 - switch (dto.getChangeType()){ - case 1: this.toCompletePurchase(dto.getDetails());break; - case 2: this.toCompleteInHouse(dto.getDetails());break; - case 3: this.toCompleteOutHouse(dto.getDetails());break; - } - - return super.updateById(entity); - } - - /** - * 采购完成 - * @return - */ - private boolean toCompletePurchase(List details){ - boolean result = true; - if(details == null || details.size()<1){ - return result; - } - List spEntities = new ArrayList<>(); - HzimsSparePartsEntity spEntity ; - for(HzimsSpChangeDetailEntity detail:details){ - spEntity = new HzimsSparePartsEntity(); - BeanUtils.copyProperties(detail,spEntity); - spEntity.setId(detail.getSpId()); - spEntity.setInPrice(detail.getPrice()); //到入库时更新 -// spEntity.setStock(detail.getQuantity()); //到入库时更新 - spEntities.add(spEntity); - } - result = this.spService.saveOrUpdateBatch(spEntities); - return result; - } - - /** - * 入库完成 - * @return - */ - private boolean toCompleteInHouse(List details){ - boolean result = true; - if(details == null || details.size()<1){ - return result; - } - List insertEntities = new ArrayList<>(); - HzimsSpWareRelatedEntity wareRelatedEntity ; - for(HzimsSpChangeDetailEntity detail:details){ - wareRelatedEntity = new HzimsSpWareRelatedEntity(); - wareRelatedEntity.setWarehouseId(detail.getWarehouseId()); - wareRelatedEntity.setSpId(detail.getSpId()); - wareRelatedEntity.setInPrice(detail.getPrice()); - wareRelatedEntity.setStock(detail.getQuantity()); - if(this.wareRelatedService.updateSelectiveInStock(wareRelatedEntity)==0){ - insertEntities.add(wareRelatedEntity); - } - } - this.wareRelatedService.saveBatch(insertEntities); - // TODO 后面考虑是否需要更新备品备件表中的库存等信息(不更新,库存就从hz_ims_sp_ware_related中取) - return result; - } - - /** - * 出库完成 - * @return - */ - private boolean toCompleteOutHouse(List details){ - boolean result = true; - if(details == null || details.size()<1){ - return result; - } - HzimsSpWareRelatedEntity wareRelatedEntity ; - for(HzimsSpChangeDetailEntity detail:details){ - wareRelatedEntity = new HzimsSpWareRelatedEntity(); - wareRelatedEntity.setWarehouseId(detail.getWarehouseId()); - wareRelatedEntity.setSpId(detail.getSpId()); - wareRelatedEntity.setOutPrice(detail.getPrice()); - wareRelatedEntity.setOutStock(detail.getQuantity()); - this.wareRelatedService.updateSelectiveOutStock(wareRelatedEntity); - // TODO 考虑是否新增批量更新接口 - } - // TODO 后面考虑是否需要更新备品备件表中的库存等信息(不更新,库存就从hz_ims_sp_ware_related中取) - return result; - } - - - @Override - public boolean removeById(Long id){ - return baseMapper.deleteByPrimaryKey(id) > 0; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpFileServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpFileServiceImpl.java deleted file mode 100644 index 5c557f9..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpFileServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import org.springblade.core.mp.base.BaseServiceImpl; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; -import com.hnac.hzims.spare.mapper.HzimsSpFileMapper; -import com.hnac.hzims.spare.service.IHzimsSpFileService; -import org.springframework.stereotype.Service; - -/** - * 备品备件文件表 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpFileServiceImpl extends BaseServiceImpl implements IHzimsSpFileService { - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpProviderServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpProviderServiceImpl.java deleted file mode 100644 index 2497c5e..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpProviderServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import org.springblade.core.mp.base.BaseServiceImpl; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; -import com.hnac.hzims.spare.mapper.HzimsSpProviderMapper; -import com.hnac.hzims.spare.service.IHzimsSpProviderService; -import org.springframework.stereotype.Service; - -/** - * 备品备件供应商 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpProviderServiceImpl extends BaseServiceImpl implements IHzimsSpProviderService { - - @Override - public boolean removeById(Long id){ - return baseMapper.deleteByPrimaryKey(id) > 0; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpRelevanceFileServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpRelevanceFileServiceImpl.java deleted file mode 100644 index c04672b..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpRelevanceFileServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import org.springblade.core.mp.base.BaseServiceImpl; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; -import com.hnac.hzims.spare.mapper.HzimsSpRelevanceFileMapper; -import com.hnac.hzims.spare.service.IHzimsSpRelevanceFileService; -import org.springframework.stereotype.Service; - -/** - * 备品备件文件关联 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpRelevanceFileServiceImpl extends BaseServiceImpl implements IHzimsSpRelevanceFileService { - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpTypeServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpTypeServiceImpl.java deleted file mode 100644 index 90538fc..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpTypeServiceImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.hnac.hzims.spare.dto.HzimsSpTypeDTO; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import com.hnac.hzims.spare.mapper.HzimsSpTypeMapper; -import com.hnac.hzims.spare.service.IHzimsSpTypeService; -import com.hnac.hzims.spare.utils.CodeDateRandomUtils; -import com.hnac.hzims.spare.utils.TreeUtil; -import com.hnac.hzinfo.common.utils.StringUtils; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 备品备件类型 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpTypeServiceImpl extends BaseServiceImpl implements IHzimsSpTypeService { - private static final String PREFIX_CODE = "SPTYPE"; - - @Override - public boolean saveOrUpdate(HzimsSpTypeEntity entity){ - entity.setUpdateTime(new Date()); - entity.setCode(StringUtils.isNotBlank(entity.getCode())?entity.getCode(): CodeDateRandomUtils.generateCode(PREFIX_CODE)); - return super.saveOrUpdate(entity); - } - - @Override - public boolean removeById(Long id){ - return baseMapper.deleteByPrimaryKey(id) > 0; - } - - @Override - public List getSpTypeTree(){ - List stList = baseMapper.selectAllSpTypeList(); - TreeUtil treeUtil = new TreeUtil(); - return treeUtil.getChildTreeObjects(stList,new Long(0)); - } - - @Override - public List getList() { - return baseMapper.getList(); - } -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWareRelatedServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWareRelatedServiceImpl.java deleted file mode 100644 index b77c5d9..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWareRelatedServiceImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; -import com.hnac.hzims.spare.mapper.HzimsSpWareRelatedMapper; -import com.hnac.hzims.spare.service.IHzimsSpWareRelatedService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 备品备件仓库备件关联表 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpWareRelatedServiceImpl implements IHzimsSpWareRelatedService { - - @Autowired - private HzimsSpWareRelatedMapper wareRelatedMapper; - - @Override - public int saveBatch(List entitys){ - int result = 0; - - if(entitys == null || entitys.size() == 0){ - return result; - } - result = this.wareRelatedMapper.insertBatch(entitys); - return result; - } - - @Override - public boolean deleteByWarehouseId(Long warehouseId){ - return wareRelatedMapper.deleteByWarehouseId(warehouseId) > 0; - } - - @Override - public int updateSelectiveInStock(HzimsSpWareRelatedEntity record){ - return this.wareRelatedMapper.updateSelectiveInStock(record); - } - @Override - public int updateSelectiveOutStock(HzimsSpWareRelatedEntity record){ - return this.wareRelatedMapper.updateSelectiveOutStock(record); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWarehouseServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWarehouseServiceImpl.java deleted file mode 100644 index 7b210b3..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSpWarehouseServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import org.springblade.core.mp.base.BaseServiceImpl; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; -import com.hnac.hzims.spare.mapper.HzimsSpWarehouseMapper; -import com.hnac.hzims.spare.service.IHzimsSpWarehouseService; -import org.springframework.stereotype.Service; - -/** - * 备品备件仓库 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSpWarehouseServiceImpl extends BaseServiceImpl implements IHzimsSpWarehouseService { - - @Override - public boolean removeById(Long id){ - return baseMapper.deleteByPrimaryKey(id) > 0; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSparePartsServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSparePartsServiceImpl.java deleted file mode 100644 index 294b035..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/HzimsSparePartsServiceImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.hnac.hzims.spare.service.impl; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hnac.hzims.spare.dto.HzimsSpareCountDTO; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import com.hnac.hzims.spare.mapper.HzimsSparePartsMapper; -import com.hnac.hzims.spare.service.IHzimsSparePartsService; -import com.hnac.hzims.spare.utils.CodeDateRandomUtils; -import com.hnac.hzinfo.common.utils.StringUtils; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * 备品备件 服务实现类 - * - * @author Chill - */ -@Service -public class HzimsSparePartsServiceImpl extends BaseServiceImpl implements IHzimsSparePartsService { - private static final String PREFIX_CODE = "SP"; - - @Override - public boolean saveOrUpdate(HzimsSparePartsEntity entity){ - entity.setUpdateTime(new Date()); - entity.setCode(StringUtils.isNotBlank(entity.getCode())?entity.getCode(): CodeDateRandomUtils.generateCode(PREFIX_CODE)); - return super.saveOrUpdate(entity); - } - - @Override - public boolean removeById(Long id){ - return baseMapper.deleteByPrimaryKey(id) > 0; - } - - @Override - public R> pageDTO(HzimsSparePartsEntity sparePartsEntity, Query query,String date) { - IPage pages = super.page(Condition.getPage(query), Condition.getQueryWrapper(sparePartsEntity)); - IPage dtoPages = new Page<>(); - List dtoList = new ArrayList<>(); - for (int i = 0; i < pages.getRecords().size(); i++) { - List list = this.selectSpareParts(pages.getRecords().get(i).getTypeId(),date); - dtoList.add(list.get(0)); - } - dtoPages.setRecords(dtoList); - dtoPages.setTotal(pages.getTotal()); - dtoPages.setCurrent(pages.getCurrent()); - dtoPages.setPages(pages.getPages()); - dtoPages.setSize(pages.getSize()); - return R.data(dtoPages); - } - - - @Override - public List selectSpareParts(Long typeId,String date) { - Map params = new HashMap<>(); - params.put("typeId",typeId); - List list = baseMapper.selectSparePartsBasic(params); - List resultList = new ArrayList<>(); - Map map = new HashMap<>(); - if(StringUtils.isNotEmpty(date)){ - map.put("date",date); - }else{ - map.put("date",new SimpleDateFormat("yyyy-MM").format(new Date())); - } - for (int i = 0; i < list.size(); i++) { - HzimsSpareCountDTO spareCountDTO = list.get(i); - map.put("spId",list.get(i).getId()); - map.put("changeType",2); - //查询入库数量和价格 - List inList = baseMapper.selectSparePartsCount(map); - if(inList.size()>0 && null !=inList.get(0)){ - spareCountDTO.setInQuantity(inList.get(0).getInQuantity()); - spareCountDTO.setInPrice(inList.get(0).getInPrice()); - }else{ - spareCountDTO.setInQuantity(0L); - spareCountDTO.setInPrice(new BigDecimal(0)); - } - //查询出库数量和价格 - map.put("changeType",3); - List outList = baseMapper.selectSparePartsCount(map); - if(outList.size()>0 && null !=outList.get(0)){ - spareCountDTO.setOutQuantity(outList.get(0).getInQuantity()); - spareCountDTO.setOutPrice(outList.get(0).getInPrice()); - }else{ - spareCountDTO.setOutQuantity(0L); - spareCountDTO.setOutPrice(new BigDecimal(0)); - } - resultList.add(spareCountDTO); - } - return resultList; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/NoticeServiceImpl.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/NoticeServiceImpl.java deleted file mode 100644 index a3846b3..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/service/impl/NoticeServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.spare.service.impl; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.spare.mapper.NoticeMapper; -import com.hnac.hzims.spare.service.INoticeService; -import org.springblade.core.mp.base.BaseServiceImpl; -import com.hnac.hzims.spare.entity.Notice; -import org.springframework.stereotype.Service; - -/** - * 服务实现类 - * - * @author Chill - */ -@Service -public class NoticeServiceImpl extends BaseServiceImpl implements INoticeService { - - @Override - public IPage selectNoticePage(IPage page, Notice notice) { - return page.setRecords(baseMapper.selectNoticePage(page, notice)); - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/CodeDateRandomUtils.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/CodeDateRandomUtils.java deleted file mode 100644 index 4836e87..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/CodeDateRandomUtils.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.hnac.hzims.spare.utils; - -import org.apache.commons.lang.StringUtils; - -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * @author Huj - * created in 2020/2/20 17:20 - * modified By: - * @description - **/ -public class CodeDateRandomUtils { - - /** - * 产生编码 - * @param prefix 前缀 - * @param interval 连接符 - * @return - */ - public static String generateCode(String prefix,String interval){ - interval = StringUtils.isNotBlank(interval)?interval.trim():""; - String code = ""; - SimpleDateFormat f = new - SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 - String date = f.format(new Date(System.currentTimeMillis())); - - if(StringUtils.isNotBlank(prefix)){ - code = code + prefix + interval; - } - - /*int random = (int)(Math.random()*9000)+1000; - code = code + random + interval ;*/ - code = code + date; - return code; - } - public static String generateCode(String prefix){ - return generateCode(prefix,null); - } - - - - /** - * 产生编码 - * @param prefix 前缀 - * @param interval 连接符 - * @return - */ - public static String generateCodeRandom(String prefix,String interval,Integer value){ - interval = StringUtils.isNotBlank(interval)?interval.trim():""; - String code = ""; - SimpleDateFormat f = new - SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 - String date = f.format(new Date(System.currentTimeMillis())); - - if(StringUtils.isNotBlank(prefix)){ - code = code + prefix + interval; - } - - value = value == null ? 1000:value; - int random = (int)(Math.random()*value)+1000; - code = code + random + interval ; - code = code + date; - return code; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeObject.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeObject.java deleted file mode 100644 index 4eef364..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeObject.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.hnac.hzims.spare.utils; - -import java.util.List; - -/** - * @author Huj - * created in 2019/11/12 - * modified By: - * 列表树形式显示的接口 - */ -public interface TreeObject { - - Long getId(); - - void setId(Long id); - - Long getParentId(); - - void setParentId(Long parentId); - - String getName(); - - void setName(String name); - - List getChildren(); - - void setChildren(List children); - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeUtil.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeUtil.java deleted file mode 100644 index cb0a47c..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/TreeUtil.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.hnac.hzims.spare.utils; - -import org.springframework.util.StringUtils; - -import java.util.*; - - -/** - * @author Huj - * created in 2019/11/12 13:39 - * modified By: - * @description 把一个list集合,里面的bean含有 parentId 转为树形式 - **/ -public class TreeUtil { - - /** - * 判断两个父ID是否相同 - * @param p1 - * @param p2 - * @return - */ - private boolean isEqualsParentId(Object p1,Object p2){ - if(p1!=null && p2!=null){ - return p1.equals(p2); - }else if(p1==null && p2 == null) { - return true; - }else if(p1==null && p2 != null) { - if("".equals(p2.toString())){ - return true; - }else{ - return false; - } - }else if(p1!=null && p2 == null) { - if("".equals(p1.toString())){ - return true; - }else{ - return false; - } - }else{ - return false; - } - } - - /** - * 根据父节点的ID获取所有子节点,该方法顶级节点必须为空 - * @param list 分类表 - * @param parentId 传入的父节点ID - * @return String - */ - public List getChildTreeObjects(List list,Object parentId) { - List returnList = new ArrayList(); - if(list!=null&&list.size()>0) { - for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - TreeObject t = (TreeObject) iterator.next(); - // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点(传过来的parentId类型必须要和t.getParentId()一样) - if (isEqualsParentId(t.getParentId(), parentId)) { - recursionFn(list, t); - returnList.add(t); - } - } - } - return returnList; - } - - /** - * 根据父节点的ID获取所有子节点,该方法顶级节点可以不为空,非树直接返回 - * @param list 分类表 - * @return String - */ - public List getChildTreeObjects(List list) { - if(list!=null&&list.size()>0) { - List topList=new ArrayList<>(); - List subList=new ArrayList<>(); - - Map idMap=new HashMap<>(); - - for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - //归并所有list的id集合 - TreeObject t = (TreeObject) iterator.next(); - idMap.put(t.getId().toString(), t.getId().toString()); - } - - for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - //获取最顶级的list - TreeObject t = (TreeObject) iterator.next(); - if(t.getParentId()==null|| StringUtils.isEmpty(t.getParentId().toString())){ - topList.add(t); - }else{ - String id=idMap.get(t.getParentId().toString()); - if(StringUtils.isEmpty(id)){ - topList.add(t); - }else{ - subList.add(t); - } - } - } - if(topList!=null&&topList.size()>0&&subList!=null&&subList.size()>0){ - List resultList=new ArrayList<>(); - for (TreeObject t:topList) { - //将儿子级别的list归并到顶级中 - List subOneList=new ArrayList<>(); - - for (TreeObject sub:subList) { - // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 - if (isEqualsParentId(sub.getParentId(), t.getId())) { - recursionFn(subList, sub); - subOneList.add(sub); - } - } - t.setChildren(subOneList); - - - resultList.add(t); - } - return resultList; - }else{ - return list; - } - } - return list; - } - - - /** - * 递归列表 - * @param list - * @param t - */ - private void recursionFn(List list, TreeObject t) { - List childList = getChildList(list, t);// 得到子节点列表 - t.setChildren(childList); - for (TreeObject tChild : childList) { - if (hasChild(list, tChild)) {// 判断是否有子节点 - //returnList.add(TreeObject); - Iterator it = childList.iterator(); - while (it.hasNext()) { - TreeObject n = (TreeObject) it.next(); - recursionFn(list, n); - } - } - } - } - - // 得到子节点列表 - private List getChildList(List list, TreeObject t) { - - List tlist = new ArrayList(); - Iterator it = list.iterator(); - while (it.hasNext()) { - TreeObject n = (TreeObject) it.next(); - if (isEqualsParentId(n.getParentId(),t.getId())) { - tlist.add(n); - } - } - return tlist; - } - List returnList = new ArrayList(); - /** - * 根据父节点的ID获取所有子节点 - * @param list 分类表 - * @param parentId 传入的父节点ID - * @param prefix 子节点前缀 - */ - public List getChildTreeObjects(List list, Object parentId,String prefix){ - if(list == null) return null; - for (Iterator iterator = list.iterator(); iterator.hasNext();) { - TreeObject node = (TreeObject) iterator.next(); - // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 - if (isEqualsParentId(node.getParentId(),parentId)) { - recursionFn(list, node,prefix); - } - // 二、遍历所有的父节点下的所有子节点 - /*if (node.getParentId()==0) { - recursionFn(list, node); - }*/ - } - return returnList; - } - - private void recursionFn(List list, TreeObject node,String p) { - List childList = getChildList(list, node);// 得到子节点列表 - if (hasChild(list, node)) {// 判断是否有子节点 - returnList.add(node); - Iterator it = childList.iterator(); - while (it.hasNext()) { - TreeObject n = (TreeObject) it.next(); - n.setName(p+n.getName()); - recursionFn(list, n,p+p); - } - } else { - returnList.add(node); - } - } - - // 判断是否有子节点 - private boolean hasChild(List list, TreeObject t) { - return getChildList(list, t).size() > 0 ? true : false; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/UserUtils.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/UserUtils.java deleted file mode 100644 index c499fcc..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/utils/UserUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hnac.hzims.spare.utils; - -import com.hnac.hzinfo.common.utils.SessionUtils; -import com.hnac.hzinfo.modules.sys.entity.User; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author Huj - * created in 2020/2/20 17:20 - * modified By: - * @description - **/ -public class UserUtils { - - public static User getCurrentUser(HttpServletRequest request){ - User user; - if(request != null){ - user = SessionUtils.getCurrentUser(request); - }else { - user = new User(); - } - return user; - } -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeDetailVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeDetailVO.java deleted file mode 100644 index 20ce7c6..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeDetailVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; - -/** - * 备品备件出入库详情 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpChangeDetailVO extends HzimsSpChangeDetailEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeRecVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeRecVO.java deleted file mode 100644 index 813a127..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpChangeRecVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; - -/** - * 备品备件出入库 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpChangeRecVO extends HzimsSpChangeRecEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpFileVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpFileVO.java deleted file mode 100644 index e178592..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpFileVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; - -/** - * 备品备件文件表 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpFileVO extends HzimsSpFileEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpProviderVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpProviderVO.java deleted file mode 100644 index c49ae0f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpProviderVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; - -/** - * 备品备件供应商 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpProviderVO extends HzimsSpProviderEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpRelevanceFileVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpRelevanceFileVO.java deleted file mode 100644 index 1879131..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpRelevanceFileVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; - -/** - * 备品备件文件关联 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpRelevanceFileVO extends HzimsSpRelevanceFileEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpTypeVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpTypeVO.java deleted file mode 100644 index b8523dd..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpTypeVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; - -/** - * 备品备件类型 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpTypeVO extends HzimsSpTypeEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWareRelatedVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWareRelatedVO.java deleted file mode 100644 index b8f7653..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWareRelatedVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; - -/** - * 备品备件仓库备件关联表 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpWareRelatedVO extends HzimsSpWareRelatedEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWarehouseVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWarehouseVO.java deleted file mode 100644 index 1cfab00..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSpWarehouseVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; - -/** - * 备品备件仓库 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSpWarehouseVO extends HzimsSpWarehouseEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSparePartsVO.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSparePartsVO.java deleted file mode 100644 index defd19f..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/vo/HzimsSparePartsVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.spare.vo; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; - -/** - * 备品备件 模型VO - * - * @author Chill - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class HzimsSparePartsVO extends HzimsSparePartsEntity { - - private static final long serialVersionUID = 1L; - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeDetailWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeDetailWrapper.java deleted file mode 100644 index 6dbaef3..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeDetailWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpChangeDetailEntity; -import com.hnac.hzims.spare.vo.HzimsSpChangeDetailVO; - -/** - * 备品备件出入库详情 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpChangeDetailWrapper extends BaseEntityWrapper { - - public static HzimsSpChangeDetailWrapper build() { - return new HzimsSpChangeDetailWrapper(); - } - - @Override - public HzimsSpChangeDetailVO entityVO(HzimsSpChangeDetailEntity spChangeDetail) { - HzimsSpChangeDetailVO spChangeDetailVO = BeanUtil.copy(spChangeDetail, HzimsSpChangeDetailVO.class); - - //User createUser = UserCache.getUser(spChangeDetail.getCreateUser()); - //User updateUser = UserCache.getUser(spChangeDetail.getUpdateUser()); - //spChangeDetailVO.setCreateUserName(createUser.getName()); - //spChangeDetailVO.setUpdateUserName(updateUser.getName()); - - return spChangeDetailVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeRecWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeRecWrapper.java deleted file mode 100644 index e08472c..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpChangeRecWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpChangeRecEntity; -import com.hnac.hzims.spare.vo.HzimsSpChangeRecVO; - -/** - * 备品备件出入库 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpChangeRecWrapper extends BaseEntityWrapper { - - public static HzimsSpChangeRecWrapper build() { - return new HzimsSpChangeRecWrapper(); - } - - @Override - public HzimsSpChangeRecVO entityVO(HzimsSpChangeRecEntity spChangeRec) { - HzimsSpChangeRecVO spChangeRecVO = BeanUtil.copy(spChangeRec, HzimsSpChangeRecVO.class); - - //User createUser = UserCache.getUser(spChangeRec.getCreateUser()); - //User updateUser = UserCache.getUser(spChangeRec.getUpdateUser()); - //spChangeRecVO.setCreateUserName(createUser.getName()); - //spChangeRecVO.setUpdateUserName(updateUser.getName()); - - return spChangeRecVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpFileWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpFileWrapper.java deleted file mode 100644 index a510e5a..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpFileWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpFileEntity; -import com.hnac.hzims.spare.vo.HzimsSpFileVO; - -/** - * 备品备件文件表 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpFileWrapper extends BaseEntityWrapper { - - public static HzimsSpFileWrapper build() { - return new HzimsSpFileWrapper(); - } - - @Override - public HzimsSpFileVO entityVO(HzimsSpFileEntity spFile) { - HzimsSpFileVO spFileVO = BeanUtil.copy(spFile, HzimsSpFileVO.class); - - //User createUser = UserCache.getUser(spFile.getCreateUser()); - //User updateUser = UserCache.getUser(spFile.getUpdateUser()); - //spFileVO.setCreateUserName(createUser.getName()); - //spFileVO.setUpdateUserName(updateUser.getName()); - - return spFileVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpProviderWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpProviderWrapper.java deleted file mode 100644 index 4127513..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpProviderWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpProviderEntity; -import com.hnac.hzims.spare.vo.HzimsSpProviderVO; - -/** - * 备品备件供应商 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpProviderWrapper extends BaseEntityWrapper { - - public static HzimsSpProviderWrapper build() { - return new HzimsSpProviderWrapper(); - } - - @Override - public HzimsSpProviderVO entityVO(HzimsSpProviderEntity spProvider) { - HzimsSpProviderVO spProviderVO = BeanUtil.copy(spProvider, HzimsSpProviderVO.class); - - //User createUser = UserCache.getUser(spProvider.getCreateUser()); - //User updateUser = UserCache.getUser(spProvider.getUpdateUser()); - //spProviderVO.setCreateUserName(createUser.getName()); - //spProviderVO.setUpdateUserName(updateUser.getName()); - - return spProviderVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpRelevanceFileWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpRelevanceFileWrapper.java deleted file mode 100644 index 4ab5313..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpRelevanceFileWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpRelevanceFileEntity; -import com.hnac.hzims.spare.vo.HzimsSpRelevanceFileVO; - -/** - * 备品备件文件关联 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpRelevanceFileWrapper extends BaseEntityWrapper { - - public static HzimsSpRelevanceFileWrapper build() { - return new HzimsSpRelevanceFileWrapper(); - } - - @Override - public HzimsSpRelevanceFileVO entityVO(HzimsSpRelevanceFileEntity spRelevanceFile) { - HzimsSpRelevanceFileVO spRelevanceFileVO = BeanUtil.copy(spRelevanceFile, HzimsSpRelevanceFileVO.class); - - //User createUser = UserCache.getUser(spRelevanceFile.getCreateUser()); - //User updateUser = UserCache.getUser(spRelevanceFile.getUpdateUser()); - //spRelevanceFileVO.setCreateUserName(createUser.getName()); - //spRelevanceFileVO.setUpdateUserName(updateUser.getName()); - - return spRelevanceFileVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpTypeWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpTypeWrapper.java deleted file mode 100644 index 04dc5e5..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpTypeWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpTypeEntity; -import com.hnac.hzims.spare.vo.HzimsSpTypeVO; - -/** - * 备品备件类型 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpTypeWrapper extends BaseEntityWrapper { - - public static HzimsSpTypeWrapper build() { - return new HzimsSpTypeWrapper(); - } - - @Override - public HzimsSpTypeVO entityVO(HzimsSpTypeEntity spType) { - HzimsSpTypeVO spTypeVO = BeanUtil.copy(spType, HzimsSpTypeVO.class); - - //User createUser = UserCache.getUser(spType.getCreateUser()); - //User updateUser = UserCache.getUser(spType.getUpdateUser()); - //spTypeVO.setCreateUserName(createUser.getName()); - //spTypeVO.setUpdateUserName(updateUser.getName()); - - return spTypeVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWareRelatedWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWareRelatedWrapper.java deleted file mode 100644 index a86dadb..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWareRelatedWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpWareRelatedEntity; -import com.hnac.hzims.spare.vo.HzimsSpWareRelatedVO; - -/** - * 备品备件仓库备件关联表 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpWareRelatedWrapper extends BaseEntityWrapper { - - public static HzimsSpWareRelatedWrapper build() { - return new HzimsSpWareRelatedWrapper(); - } - - @Override - public HzimsSpWareRelatedVO entityVO(HzimsSpWareRelatedEntity spWareRelated) { - HzimsSpWareRelatedVO spWareRelatedVO = BeanUtil.copy(spWareRelated, HzimsSpWareRelatedVO.class); - - //User createUser = UserCache.getUser(spWareRelated.getCreateUser()); - //User updateUser = UserCache.getUser(spWareRelated.getUpdateUser()); - //spWareRelatedVO.setCreateUserName(createUser.getName()); - //spWareRelatedVO.setUpdateUserName(updateUser.getName()); - - return spWareRelatedVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWarehouseWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWarehouseWrapper.java deleted file mode 100644 index 31a9ac1..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSpWarehouseWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSpWarehouseEntity; -import com.hnac.hzims.spare.vo.HzimsSpWarehouseVO; - -/** - * 备品备件仓库 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSpWarehouseWrapper extends BaseEntityWrapper { - - public static HzimsSpWarehouseWrapper build() { - return new HzimsSpWarehouseWrapper(); - } - - @Override - public HzimsSpWarehouseVO entityVO(HzimsSpWarehouseEntity spWarehouse) { - HzimsSpWarehouseVO spWarehouseVO = BeanUtil.copy(spWarehouse, HzimsSpWarehouseVO.class); - - //User createUser = UserCache.getUser(spWarehouse.getCreateUser()); - //User updateUser = UserCache.getUser(spWarehouse.getUpdateUser()); - //spWarehouseVO.setCreateUserName(createUser.getName()); - //spWarehouseVO.setUpdateUserName(updateUser.getName()); - - return spWarehouseVO; - } - -} diff --git a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSparePartsWrapper.java b/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSparePartsWrapper.java deleted file mode 100644 index fec9bb4..0000000 --- a/hzims-service/spare/src/main/java/com/hnac/hzims/spare/wrapper/HzimsSparePartsWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.spare.wrapper; - -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import com.hnac.hzims.spare.entity.HzimsSparePartsEntity; -import com.hnac.hzims.spare.vo.HzimsSparePartsVO; - -/** - * 备品备件 包装类,返回视图层所需的字段 - * - * @author Chill - */ -public class HzimsSparePartsWrapper extends BaseEntityWrapper { - - public static HzimsSparePartsWrapper build() { - return new HzimsSparePartsWrapper(); - } - - @Override - public HzimsSparePartsVO entityVO(HzimsSparePartsEntity spareParts) { - HzimsSparePartsVO sparePartsVO = BeanUtil.copy(spareParts, HzimsSparePartsVO.class); - - //User createUser = UserCache.getUser(spareParts.getCreateUser()); - //User updateUser = UserCache.getUser(spareParts.getUpdateUser()); - //sparePartsVO.setCreateUserName(createUser.getName()); - //sparePartsVO.setUpdateUserName(updateUser.getName()); - - return sparePartsVO; - } - -} diff --git a/hzims-service/spare/src/test/java/BladeDemoTest.java b/hzims-service/spare/src/test/java/BladeDemoTest.java deleted file mode 100644 index 22eccde..0000000 --- a/hzims-service/spare/src/test/java/BladeDemoTest.java +++ /dev/null @@ -1,31 +0,0 @@ -import com.hnac.hzims.spare.SpareApplication; -import com.hnac.hzims.spare.service.INoticeService; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springblade.core.test.BladeBootTest; -import org.springblade.core.test.BladeSpringRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -/** - * Blade单元测试 - * - * @author Chill - */ -@Ignore -@RunWith(BladeSpringRunner.class) -@SpringBootTest(classes = SpareApplication.class) -@BladeBootTest(appName = "blade-demo", profile = "test", enableLoader = true) -public class BladeDemoTest { - - @Autowired - private INoticeService noticeService; - - @Test - public void contextLoads() { - int count = noticeService.count(); - System.out.println("notice数量:[" + count + "] 个"); - } - -} diff --git a/hzims-service/spare/src/test/java/launcher/DemoTestLauncherServiceImpl.java b/hzims-service/spare/src/test/java/launcher/DemoTestLauncherServiceImpl.java deleted file mode 100644 index 2cdf29f..0000000 --- a/hzims-service/spare/src/test/java/launcher/DemoTestLauncherServiceImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package launcher; - -import com.hnac.hzims.common.constant.LauncherConstant; -import org.junit.Ignore; -import org.springblade.core.auto.service.AutoService; -import org.springblade.core.launch.service.LauncherService; -import org.springframework.boot.builder.SpringApplicationBuilder; - -import java.util.Properties; - -/** - * 启动参数拓展 - * - * @author Chill - */ -@AutoService(LauncherService.class) -@Ignore -public class DemoTestLauncherServiceImpl implements LauncherService { - - @Override - public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { - Properties props = System.getProperties(); - props.setProperty("spring.cloud.nacos.discovery.server-addr", LauncherConstant.NACOS_DEV_ADDR); - props.setProperty("spring.cloud.nacos.config.server-addr", LauncherConstant.NACOS_DEV_ADDR); - props.setProperty("spring.cloud.sentinel.transport.dashboard", LauncherConstant.SENTINEL_DEV_ADDR); - } - - @Override - public int getOrder() { - return 10; - } -} From af7529a008590eccbae62c3d337293a848cbfaf0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 17 May 2024 16:28:29 +0800 Subject: [PATCH 047/151] =?UTF-8?q?fix:=E5=B7=A5=E4=BD=9C=E7=A5=A8?= =?UTF-8?q?=E9=99=84=E8=A1=A8=E9=A2=84=E8=A7=88=E8=A1=A5=E5=85=85=E5=8D=B1?= =?UTF-8?q?=E9=99=A9=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../twoTicket/service/impl/FirstWorkTicketServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java index 4ff1b08..ca1e8fb 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java @@ -24,9 +24,12 @@ import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.WorkTicketConstants; import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant; +import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; +import com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper; import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService; +import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService; import com.hnac.hzims.ticket.utils.*; import com.hnac.hzims.ticket.workTicket.dto.*; import com.hnac.hzims.ticket.workTicket.entity.*; @@ -103,6 +106,7 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl qw = Wrappers.lambdaQuery().eq(TicketInfoDanger::getTicketId, ticketId); + List ticketInfoDangerList = dangerService.list(qw); + List dangerList = IntStream.iterate(0, index -> index + 1).limit(ticketInfoDangerList.size()).mapToObj(index -> { + Map result = ObjectUtils.obj2Map(ticketInfoDangerList.get(index)); + result.put("index",index + 1); + return result; + }).collect(Collectors.toList()); + params.put("ticketInfoDangers", dangerList); params.put("isSafety",workTicketInfoEntity.getIsSafety() ? "☑" : "□"); params.put("isHazard",workTicketInfoEntity.getIsHazard() ? "☑" : "□"); params.put("isRailway",workTicketInfoEntity.getIsRailway() ? "☑" : "□"); From 5ad63934bee434fe8866461f9ffc16964e10cd2f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 21 May 2024 11:51:23 +0800 Subject: [PATCH 048/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 5 ++- hzims-service-api/pom.xml | 1 - .../interactive/constants/FuncRouteEnum.java | 17 ++++++---- .../service/impl/ExtraResolveStrategyService.java | 25 ++++++++++++++ .../bigmodel/interactive/vo/RemoteParamVO.java | 39 ++++++++++++++++++++++ .../bigmodel/interactive/vo/SessionContentVO.java | 19 +++++++++++ .../websocket/constants/RedisKeyConstants.java | 13 ++++++++ .../websocket/handler/InteractiveHandler.java | 9 +++++ .../controller/StationVideoTypeController.java | 6 ++++ .../station/service/IStationVideoTypeService.java | 3 ++ .../station/service/impl/StationServiceImpl.java | 8 +++++ .../service/impl/StationVideoTypeServiceImpl.java | 8 +++++ hzims-service/pom.xml | 1 - pom.xml | 2 +- 14 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 7114de1..6a2d62d 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -20,7 +20,10 @@ public interface FunctionConstants { LINK("2"), /**参数**/ PARAMS("3"), - CHOOSE("4") + /**选项**/ + CHOOSE("4"), + /**确认**/ + CONFIRM("5") ; @Getter private String type; diff --git a/hzims-service-api/pom.xml b/hzims-service-api/pom.xml index 59661cf..e19eb31 100644 --- a/hzims-service-api/pom.xml +++ b/hzims-service-api/pom.xml @@ -29,7 +29,6 @@ middle-api alarm-api big-model-api - suichang-api 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 3dd1caf..174df24 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 @@ -12,18 +12,21 @@ import java.util.Optional; */ @AllArgsConstructor public enum FuncRouteEnum { - OPEN_CANVAS("open_canvas","打开实时画面"), - OPEN_VIDEO("open_video","打开视频监控"), - DIAGNOSE("diagnose","智能诊断"), - CHOOSE_STATION("choose_station","选择站点"), - CHOOSE_VIDEO("choose_video","选择视频"), - CHOOSE_CANVAS("choose_canvas","选择画面"), - CHOOSE_FAULT("choose_fault","选择故障"), + OPEN_CANVAS("open_canvas","打开实时画面",null), + OPEN_VIDEO("open_video","打开视频监控",null), + DIAGNOSE("diagnose","智能诊断",null), + CHOOSE_STATION("choose_station","选择站点",null), + CHOOSE_VIDEO("choose_video","选择视频",null), + CHOOSE_CANVAS("choose_canvas","选择画面",null), + CHOOSE_FAULT("choose_fault","选择故障",null), + CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.CONFIRM), ; @Getter private String funcCode; @Getter private String funcName; + @Getter + private FunctionConstants.TypeEnum type; public static FuncRouteEnum getEnumByFuncCode(String funcCode) { Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index c1895b9..c464e05 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -6,16 +6,22 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.vo.*; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.ControlDTO; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -35,6 +41,8 @@ public class ExtraResolveStrategyService { private final IStationClient stationClient; private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; + private final DeviceClient deviceClient; + private final RedisTemplate redisTemplate; /** * 解析DFP返回extra @@ -59,6 +67,8 @@ public class ExtraResolveStrategyService { return this.resolveChooseScada(extra); case CHOOSE_FAULT: return this.resolveChooseFault(extra); + case CONFIRM_YK: + return this.resolveConfirmRemote(extra); default: break; } @@ -67,6 +77,21 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveConfirmRemote(Map extra) { + ExtraVO result = new ExtraVO(); + RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); + result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode()); + result.setType(FunctionConstants.TypeEnum.CONFIRM.getType()); + R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); + if(funcVOR.isSuccess()) { + Map param = new HashMap(1); + param.put("control",funcVOR.getData()); + param.put("value",remoteParam.getValue()); + result.setParams(param); + } + return result; + } + private ExtraVO resolveChooseFault(Map extra) { ExtraVO result = new ExtraVO(); JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java new file mode 100644 index 0000000..3bcf351 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 14:46 + */ +@Data +@EqualsAndHashCode +public class RemoteParamVO implements Serializable { + + @JSONField(name = "id") + private String funcId; + + @JSONField(name = "yk_name") + private String remoteName; + + @JSONField(name = "device_id") + private String deviceCode; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String value; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java new file mode 100644 index 0000000..1de0532 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SessionContentVO.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:31 + */ +@Data +@EqualsAndHashCode +public class SessionContentVO implements Serializable { + + /**机器码**/ + private String machineCode; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java new file mode 100644 index 0000000..3cd0e30 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/constants/RedisKeyConstants.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.bigmodel.websocket.constants; + +import com.hnac.hzims.common.constant.CommonConstant; + +/** + * @Author: huangxing + * @Date: 2024/05/20 19:11 + */ +public interface RedisKeyConstants { + + String SESSION_CONTENT_KEY = CommonConstant.TENANT_ID + ":hzims:bigModel:session:content"; + +} 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 96dfc4e..c1b9976 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 @@ -9,12 +9,14 @@ import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -23,6 +25,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.function.Function; /** @@ -64,6 +67,12 @@ public class InteractiveHandler extends TextWebSocketHandler { } }else { String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); + if(Func.isNotEmpty(messageJSON.containsKey("content"))) { + // 将发送参数存入redis + RedisTemplate redisTemplate = SpringUtil.getBean(RedisTemplate.class); + redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); + redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); + } this.handleMessage(messageJSON,sessionId); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index 3639cb9..f69936d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -354,4 +354,10 @@ public class StationVideoTypeController extends BladeController { return R.data(false); } + @GetMapping ("/getVideoByPointCodes") + @ApiOperationSupport(order = 190) + @ApiOperation(value = "通过视频编号获取视频") + public R> getVideoByPointCodes(@RequestParam @ApiParam("视频设备编号") String pointCodes) { + return R.data(stationVideoTypeService.getVideoByPointCodes(pointCodes)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index f008b57..bd5a5b1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -10,6 +10,7 @@ import com.hnac.hzims.operational.station.response.HikMonitorResp; import com.hnac.hzims.operational.station.vo.HikVideoAreaTreeVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO; +import io.swagger.annotations.ApiParam; import org.apache.ibatis.annotations.Param; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; @@ -83,4 +84,6 @@ public interface IStationVideoTypeService extends BaseService getVideoByPointCodes(String pointCodes); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 7976d98..aa58a0f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -690,6 +690,14 @@ public class StationServiceImpl extends BaseServiceImpl wq = Wrappers.lambdaQuery().eq(StationEntity::getCode, entity.getCode()); + List stations = this.getBaseMapper().listWithOutAuth(wq); + Assert.isTrue(CollectionUtil.isEmpty(stations),() -> { + throw new ServiceException("站点编号平台已存在,请检查后重新填入!"); + }); + } Integer maxSort = this.baseMapper.getMaxSort(); entity.setSort(Optional.ofNullable(maxSort).map(sort -> sort + 1).orElse(1)); // 创建站点机构 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index 94e544a..671e71f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -279,6 +279,14 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl getVideoByPointCodes(String pointCodes) { + List pointCodeList = Func.toStrList(",", pointCodes); + LambdaQueryWrapper qw = Wrappers.lambdaQuery().in(StationVideoTypeEntity::getPointCode, pointCodeList); + List videoList = this.list(qw); + return videoList; + } + private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) { HikVideoAreaTreeVO parentTree = BeanUtil.copy(area,HikVideoAreaTreeVO.class); if(CollectionUtil.isNotEmpty(videoAreaMapByParent.get(area.getIndexCode()))) { diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index 8c59a54..8812762 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -29,7 +29,6 @@ hzims-alarm hzims-basic hzims-big-model - suichang hzims-simulate diff --git a/pom.xml b/pom.xml index 47b1aaa..e3c6ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - 5.1.1.RELEASE.fix.4 + 5.1.1.RELEASE.fix.5 com.xuxueli From 89ec1c4bf6832a4934b0f6598437e26632835e68 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 21 May 2024 11:52:19 +0800 Subject: [PATCH 049/151] =?UTF-8?q?update:=20=E6=99=BA=E8=83=BD=E9=97=AE?= =?UTF-8?q?=E7=AD=94=E5=A2=9E=E5=8A=A0=E8=B0=83=E7=94=A8=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E9=97=AE=E7=AD=94=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 1 + .../interactive/service/IInteractiveService.java | 13 ++++++++--- .../service/impl/InteractiveServiceImpl.java | 25 ++++++++++++++++++++++ .../websocket/handler/InteractiveHandler.java | 18 ++++++++++------ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 7f8d6d5..8179cba 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -27,4 +27,5 @@ public class BigModelInvokeUrl { private String updateCanvas; + private String assistantKnowledgeAsk; } 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 40b06ea..241a25b 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 @@ -2,11 +2,8 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import io.swagger.annotations.ApiParam; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RequestParam; -import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -33,4 +30,14 @@ public interface IInteractiveService { Boolean authentication(String stationId, String userId, String func); Boolean removeSessionId(String sessionId); + + /** + * 发起知识库问答 + * @param question 问题 + * @param sessionId 会话id + * @param userId 用户id + * @param knowledge 知识库名称 + * @return 发起结果 + */ + R knowledgeAsk(String question, String sessionId, String userId, String knowledge); } 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 4e835a0..f150638 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 @@ -246,6 +246,31 @@ public class InteractiveServiceImpl implements IInteractiveService { return true; } + /** + * 发起知识库问答 + */ + @Override + public R knowledgeAsk(String question, String sessionId, String userId, String knowledge) { + Map params = new HashMap<>(); + params.put("id", sessionId); + params.put("userid", userId); + params.put("query", question); + params.put("knowledge", knowledge); + params.put("stationids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) + .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) + .filter(Func::isNotEmpty).map(String::valueOf).toArray()); + HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk()) + .body(JSON.toJSONString(params)).execute(); + logger.info("interactive:knowledgeAsk", "知识库问答传参为:" + JSON.toJSONString(params) + " 结果为:" + response.body()); + if (response.getStatus() != HttpServletResponse.SC_OK) { + log.error("远程调用大模型【发起知识库问答】接口失败!"); + return R.fail("远程调用大模型【发起知识库问答】接口失败!"); + } + this.addQuestionSessionId(sessionId); + return R.success("消息发送成功"); + } + private List getStationPermissionsById(String userId) { R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { 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 96dfc4e..585b15e 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 @@ -62,20 +62,26 @@ public class InteractiveHandler extends TextWebSocketHandler { } catch (IOException e) { throw new RuntimeException(e); } - }else { + } else { String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); - this.handleMessage(messageJSON,sessionId); + this.handleMessage(messageJSON, sessionId); } } - private void handleMessage(JSONObject messageContext,String sessionId) { + private void handleMessage(JSONObject messageContext, String sessionId) { Boolean isSpecial = messageContext.getBoolean("isSpecial"); - if(Func.isEmpty(isSpecial) || !isSpecial) { + if (Func.isEmpty(isSpecial) || !isSpecial) { String context = messageContext.getString("context"); String userId = messageContext.getString("userId"); + String knowledge = messageContext.getString("knowledge"); IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - R askResult = interactiveService.ask(context, sessionId, userId); - log.info("返回结果为:"+ JSON.toJSONString(askResult)); + if (knowledge != null) { + R askResult = interactiveService.knowledgeAsk(context, sessionId, userId, knowledge); + log.info("知识库问答返回结果:" + JSON.toJSONString(askResult)); + } else { + R askResult = interactiveService.ask(context, sessionId, userId); + log.info("返回结果为:"+ JSON.toJSONString(askResult)); + } } else { String funcCode = messageContext.getString("funcCode"); From 8a172849bead5048a686b01e6b6f9c6862148807 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 21 May 2024 15:25:26 +0800 Subject: [PATCH 050/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/constants/FuncRouteEnum.java | 2 +- .../service/impl/ExtraResolveStrategyService.java | 2 +- .../bigmodel/websocket/handler/InteractiveHandler.java | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 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 174df24..46887e8 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 @@ -19,7 +19,7 @@ public enum FuncRouteEnum { CHOOSE_VIDEO("choose_video","选择视频",null), CHOOSE_CANVAS("choose_canvas","选择画面",null), CHOOSE_FAULT("choose_fault","选择故障",null), - CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.CONFIRM), + CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index c464e05..a9c63a6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -81,7 +81,7 @@ public class ExtraResolveStrategyService { ExtraVO result = new ExtraVO(); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode()); - result.setType(FunctionConstants.TypeEnum.CONFIRM.getType()); + result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); if(funcVOR.isSuccess()) { Map param = new HashMap(1); 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 0f3d200..23b8d2e 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 @@ -12,11 +12,16 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -33,7 +38,12 @@ import java.util.function.Function; * @Date: 2024/04/28 13:45 */ @Slf4j +@Component public class InteractiveHandler extends TextWebSocketHandler { + + @Autowired + private RedisTemplate redisTemplate; + @Override public void afterConnectionEstablished(WebSocketSession session) { String[] split = session.getUri().toString().split("/"); @@ -67,9 +77,8 @@ public class InteractiveHandler extends TextWebSocketHandler { } } else { String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); - if(Func.isNotEmpty(messageJSON.containsKey("content"))) { + if(messageJSON.containsKey("content")) { // 将发送参数存入redis - RedisTemplate redisTemplate = SpringUtil.getBean(RedisTemplate.class); redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); } From bea6be45135924d9218553fdb9f366caabfb9659 Mon Sep 17 00:00:00 2001 From: RnhaiWang <393727820@qq.com> Date: Tue, 21 May 2024 15:27:56 +0800 Subject: [PATCH 051/151] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java index df18dbe..6cd2907 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java @@ -48,6 +48,14 @@ public class TaskEntity extends TenantEntity { @ApiModelProperty(value = "计划名称") @QueryField(condition = SqlCondition.LIKE) private String planName; + + /** + * 路线名称 + */ + @ApiModelProperty(value = "路线名称") + @QueryField(condition = SqlCondition.LIKE) + private String routeName; + /** * 任务批次号 */ From c7a3b8bf7332ad426561bb130b33f0965f7225c2 Mon Sep 17 00:00:00 2001 From: RnhaiWang <393727820@qq.com> Date: Tue, 21 May 2024 17:24:23 +0800 Subject: [PATCH 052/151] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java | 1 + .../java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotTaskTransParam.java | 4 ++++ .../java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java | 1 + 3 files changed, 6 insertions(+) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java index e2912b5..1ec39a8 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java @@ -236,6 +236,7 @@ public class RobotTaskServiceImpl extends BaseServiceImpl Date: Tue, 21 May 2024 19:17:12 +0800 Subject: [PATCH 053/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/ProjectRemoteTypeEnum.java | 22 +++++ .../service/impl/AuthenticationService.java | 100 +++++++++++++++++++++ .../service/impl/InteractiveServiceImpl.java | 43 +++------ 3 files changed, 136 insertions(+), 29 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java new file mode 100644 index 0000000..069572a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ProjectRemoteTypeEnum.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author: huangxing + * @Date: 2024/05/21 16:34 + */ +@AllArgsConstructor +public enum ProjectRemoteTypeEnum { + /**不允许发送遥控**/ + NOT_ALLOW(0), + /**运行发送遥控并且需要校验权限**/ + VALID(1), + /**运行发送遥控并免校验权限**/ + ALLOW(2), + ; + @Getter + private Integer ctrlType; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java new file mode 100644 index 0000000..f5b9d5b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java @@ -0,0 +1,100 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; +import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +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.dto.DeptStationDTO; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.IRemoteClient; +import org.springblade.system.user.feign.IUserClient; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/05/21 16:10 + */ +@Service +@AllArgsConstructor +public class AuthenticationService { + + private final IDeptClient deptClient; + private final IFunctionService functionService; + private final IUserClient userClient; + private final ProjectClient projectClient; + private final IRemoteClient remoteClient; + + /** + * 站点鉴权 + * @param stationId 站点ID + * @param userId 用户ID + */ + public void stationAuthentication(String stationId, String userId) { + List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) + .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); + Assert.isTrue(stations.contains(stationId),() -> { + throw new ServiceException("人员站点鉴权失败!"); + }); + } + + /** + * 菜单鉴权 + * @param stationId 站点ID + * @param userId 用户ID + * @param func 函数编号 + */ + public void menuAuthentication(String stationId, String userId, String func) { + FunctionEntity function = functionService.getFunctionByCode(func); + if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { + R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); + Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { + throw new ServiceException("人员菜单鉴权失败!"); + }); + } + } + + /** + * 遥控鉴权 + * @param stationId 站点ID + * @param userId 用户ID + * @param func 函数编号 + */ + public void remoteAuthentication(String stationId, String userId, String func) { + // 查询数据平台站点是否可被遥控 + Result projectR = projectClient.getProjectByPid(stationId); + Assert.isTrue(projectR.isSuccess() && Func.isNotEmpty(projectR.getData()),() -> { + throw new ServiceException("未查询到站点,鉴权失败!"); + }); + ProjectVO project = projectR.getData(); + if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { + // 不允许发送遥控 + throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); + } + else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { + // 运行发送遥控并且需要校验权限 + //remoteClient.sendCtrlCheckParam(); + } + + } + + public List getStationPermissionsById(String userId) { + R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + return deptSattionR.getData(); + } + +} 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 f150638..d322d1d 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 @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; @@ -57,9 +58,7 @@ public class InteractiveServiceImpl implements IInteractiveService { private final BigModelInvokeUrl bigModelInvokeUrl; - private final IDeptClient deptClient; - - private final IUserClient userClient; + private final AuthenticationService authenticationService; private final RedisTemplate redisTemplate; @@ -98,8 +97,8 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("id",sessionId); params.put("userid", userId); params.put("query",question); - params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); + params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body()); @@ -132,8 +131,8 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("id",sessionId); params.put("userid", userId); params.put("extra",extra); - params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); + params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk()) .body(JSON.toJSONString(params)).execute(); if(response.getStatus() != HttpServletResponse.SC_OK) { @@ -200,21 +199,15 @@ public class InteractiveServiceImpl implements IInteractiveService { public Boolean authentication(String stationId, String userId, String func) { // 站点鉴权 if(StringUtil.isNotBlank(stationId)) { - List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) - .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); - Assert.isTrue(stations.contains(stationId),() -> { - throw new ServiceException("人员站点鉴权失败!"); - }); + authenticationService.stationAuthentication(stationId,userId); } // 菜单鉴权 if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { - FunctionEntity function = functionService.getFunctionByCode(func); - if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { - R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); - Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { - throw new ServiceException("人员菜单鉴权失败!"); - }); - } + authenticationService.menuAuthentication(stationId,userId,func); + } + // 遥控鉴权 + if(FuncRouteEnum.CONFIRM_YK.getFuncCode().equals(func)) { + authenticationService.remoteAuthentication(stationId,userId,func); } return true; } @@ -256,9 +249,9 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("userid", userId); params.put("query", question); params.put("knowledge", knowledge); - params.put("stationids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) + params.put("stationids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) + params.put("projectids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) .filter(Func::isNotEmpty).map(String::valueOf).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk()) .body(JSON.toJSONString(params)).execute(); @@ -270,12 +263,4 @@ public class InteractiveServiceImpl implements IInteractiveService { this.addQuestionSessionId(sessionId); return R.success("消息发送成功"); } - - private List getStationPermissionsById(String userId) { - R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); - Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { - throw new ServiceException("获取人员站点权限失败!"); - }); - return deptSattionR.getData(); - } } From 893d05d0bf7371e05e93fec5d8a789ef5592c433 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 21 May 2024 20:31:16 +0800 Subject: [PATCH 054/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InteractiveController.java | 5 ++-- .../interactive/service/IInteractiveService.java | 2 +- .../service/impl/AuthenticationService.java | 34 ++++++++++++++++++---- .../service/impl/InteractiveServiceImpl.java | 6 ++-- 4 files changed, 36 insertions(+), 11 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 90102a3..25de021 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,9 @@ 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 func) { - return R.status(interactiveService.authentication(stationId,userId,func)); + @RequestParam(required = false) @ApiParam("菜单ID") String func, + @RequestParam(required = false) @ApiParam("会话ID")String sessionId) { + return R.status(interactiveService.authentication(stationId,userId,func,sessionId)); } @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 241a25b..8ace8cc 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 @@ -27,7 +27,7 @@ public interface IInteractiveService { List getAnswerBySessionIds(String sessionIds); - Boolean authentication(String stationId, String userId, String func); + Boolean authentication(String stationId, String userId, String func,String sessionId); Boolean removeSessionId(String sessionId); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java index f5b9d5b..1960da9 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java @@ -3,6 +3,8 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; +import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; @@ -13,13 +15,16 @@ 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.dto.DeptStationDTO; +import org.springblade.system.entity.CtrlAuth; import org.springblade.system.feign.IDeptClient; import org.springblade.system.feign.IRemoteClient; import org.springblade.system.user.feign.IUserClient; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; /** @@ -35,6 +40,7 @@ public class AuthenticationService { private final IUserClient userClient; private final ProjectClient projectClient; private final IRemoteClient remoteClient; + private final RedisTemplate redisTemplate; /** * 站点鉴权 @@ -51,11 +57,10 @@ public class AuthenticationService { /** * 菜单鉴权 - * @param stationId 站点ID * @param userId 用户ID * @param func 函数编号 */ - public void menuAuthentication(String stationId, String userId, String func) { + public void menuAuthentication(String userId, String func) { FunctionEntity function = functionService.getFunctionByCode(func); if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); @@ -69,9 +74,8 @@ public class AuthenticationService { * 遥控鉴权 * @param stationId 站点ID * @param userId 用户ID - * @param func 函数编号 */ - public void remoteAuthentication(String stationId, String userId, String func) { + public void remoteAuthentication(String stationId, String userId,String sessionId) { // 查询数据平台站点是否可被遥控 Result projectR = projectClient.getProjectByPid(stationId); Assert.isTrue(projectR.isSuccess() && Func.isNotEmpty(projectR.getData()),() -> { @@ -84,7 +88,27 @@ public class AuthenticationService { } else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { // 运行发送遥控并且需要校验权限 - //remoteClient.sendCtrlCheckParam(); + R> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); + Assert.isTrue(ctrlAuthR.isSuccess(),() -> { + throw new ServiceException("该站点未设置鉴权用户,校验失败!"); + }); + List ctrlAuthList = ctrlAuthR.getData(); + Optional authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); + Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { + throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); + }); + CtrlAuth ctrlAuth = authOptional.get(); + // 如限制机器发送遥控指令 + if(ctrlAuth.getIsLimitMachine().intValue() == 1) { + SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); + String machineCode = sessionContent.getMachineCode(); + Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); + Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { + throw new ServiceException("站点校验码校验失败,校验不通过!"); + }); + } } } 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 d322d1d..a27ef9a 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 @@ -196,18 +196,18 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override - public Boolean authentication(String stationId, String userId, String func) { + public Boolean authentication(String stationId, String userId, String func,String sessionId) { // 站点鉴权 if(StringUtil.isNotBlank(stationId)) { authenticationService.stationAuthentication(stationId,userId); } // 菜单鉴权 if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { - authenticationService.menuAuthentication(stationId,userId,func); + authenticationService.menuAuthentication(userId,func); } // 遥控鉴权 if(FuncRouteEnum.CONFIRM_YK.getFuncCode().equals(func)) { - authenticationService.remoteAuthentication(stationId,userId,func); + authenticationService.remoteAuthentication(stationId,userId,sessionId); } return true; } From 05282c062e1dbe44e1febab7a83f4356c5bb1103 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 22 May 2024 15:12:09 +0800 Subject: [PATCH 055/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InteractiveController.java | 4 +-- .../service/impl/AuthenticationService.java | 7 ++-- .../hzims/bigmodel/interactive/vo/DataItemVO.java | 39 ++++++++++++++++++++++ .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 28 ++++++++++++++++ 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java 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 25de021..3c9788c 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 @@ -49,8 +49,8 @@ public class InteractiveController { public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("用户ID") String userId, @RequestParam(required = false) @ApiParam("菜单ID") String func, - @RequestParam(required = false) @ApiParam("会话ID")String sessionId) { - return R.status(interactiveService.authentication(stationId,userId,func,sessionId)); + @RequestParam(required = false) @ApiParam("会话ID")String askId) { + return R.status(interactiveService.authentication(stationId,userId,func,askId)); } @ApiOperation("获取问答sessionId") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java index 1960da9..f836450 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; @@ -77,11 +78,11 @@ public class AuthenticationService { */ public void remoteAuthentication(String stationId, String userId,String sessionId) { // 查询数据平台站点是否可被遥控 - Result projectR = projectClient.getProjectByPid(stationId); - Assert.isTrue(projectR.isSuccess() && Func.isNotEmpty(projectR.getData()),() -> { + Result> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); + Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { throw new ServiceException("未查询到站点,鉴权失败!"); }); - ProjectVO project = projectR.getData(); + ProjectVO project = projectR.getData().get(0); if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { // 不允许发送遥控 throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java new file mode 100644 index 0000000..914f25b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:20 + */ +@Data +public class DataItemVO implements Serializable { + + private String name; + + @JSONField(name = "id") + private String attrId; + + @JSONField(name = "param_name") + private String attrName; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "device_id") + private String deviceId; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String units; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java new file mode 100644 index 0000000..a94a2bc --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:28 + */ +@Data +public class DataVO implements Serializable { + + /**数据查询类型:实时、历史**/ + private String type; + + private String startTime; + + private String endTime; + + /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ + private String method; + + /**实时数据结果集**/ + private Map real; + +} From eede11fea92d6ac28bcafac85e11401638cd5872 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 22 May 2024 15:27:37 +0800 Subject: [PATCH 056/151] =?UTF-8?q?#=E4=B8=8B=E5=8F=91=E9=81=A5=E6=8E=A7?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/controller/InteractiveController.java | 11 ++++++++++- .../bigmodel/interactive/service/IInteractiveService.java | 3 +++ .../interactive/service/impl/InteractiveServiceImpl.java | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) 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 3c9788c..a80b2aa 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 @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.controller; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; @@ -12,9 +13,12 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; /** * @Author: huangxing @@ -67,5 +71,10 @@ public class InteractiveController { return R.data(interactiveService.removeSessionId(sessionId)); } - + @ApiOperation("下发遥控指令") + @ApiOperationSupport(order = 6) + @PostMapping("/sendRemoteControl") + public R sendRemoteControl(@RequestBody ControlDTO operate) { + return R.data(interactiveService.sendRemoteControl(operate)); + } } 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 8ace8cc..34c0a4f 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 @@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; import java.util.List; import java.util.Map; @@ -40,4 +41,6 @@ public interface IInteractiveService { * @return 发起结果 */ R knowledgeAsk(String question, String sessionId, String userId, String knowledge); + + Object sendRemoteControl(ControlDTO operate); } 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 a27ef9a..0395fd4 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 @@ -24,8 +24,10 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.IRemoteClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -50,6 +52,8 @@ public class InteractiveServiceImpl implements IInteractiveService { private final BladeLogger logger; + private final IRemoteClient remoteClient; + private final IJumpPageService jumpPageService; private final IParamsService paramsService; @@ -263,4 +267,14 @@ public class InteractiveServiceImpl implements IInteractiveService { this.addQuestionSessionId(sessionId); return R.success("消息发送成功"); } + + /** + * 下发遥控指令 + * @param operate + * @return + */ + @Override + public Object sendRemoteControl(ControlDTO operate) { + return remoteClient.sendCtrl(operate); + } } From 69cacf370a2478c6ce657ce9181e7ffd818f271f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 22 May 2024 16:27:59 +0800 Subject: [PATCH 057/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/constants/FuncRouteEnum.java | 1 + .../service/impl/ExtraResolveStrategyService.java | 15 +++++++++++++++ .../com/hnac/hzims/bigmodel/interactive/vo/DataVO.java | 3 +++ 3 files changed, 19 insertions(+) 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 46887e8..4b1d359 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 @@ -20,6 +20,7 @@ public enum FuncRouteEnum { CHOOSE_CANVAS("choose_canvas","选择画面",null), CHOOSE_FAULT("choose_fault","选择故障",null), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), + SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index a9c63a6..bcda8cb 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -69,6 +69,8 @@ public class ExtraResolveStrategyService { return this.resolveChooseFault(extra); case CONFIRM_YK: return this.resolveConfirmRemote(extra); + case SHOW_PARAM: + return this.resolveShowParam(extra); default: break; } @@ -77,6 +79,17 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveShowParam(Map extra) { + ExtraVO result = new ExtraVO(); + result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); + result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); + Map param = new HashMap(1); + DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); + param.put("data", data); + result.setParams(param); + return result; + } + private ExtraVO resolveConfirmRemote(Map extra) { ExtraVO result = new ExtraVO(); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); @@ -86,6 +99,8 @@ public class ExtraResolveStrategyService { if(funcVOR.isSuccess()) { Map param = new HashMap(1); param.put("control",funcVOR.getData()); + param.put("deviceName",remoteParam.getDeviceName()); + param.put("projectName",remoteParam.getProjectName()); param.put("value",remoteParam.getValue()); result.setParams(param); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java index a94a2bc..97dfe29 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.vo; +import com.alibaba.fastjson.annotation.JSONField; import lombok.Data; import java.io.Serializable; @@ -15,8 +16,10 @@ public class DataVO implements Serializable { /**数据查询类型:实时、历史**/ private String type; + @JSONField(name = "time_begin") private String startTime; + @JSONField(name = "time_end") private String endTime; /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ From 5ff72180306f71d5793a1324986a773be27abf4b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 23 May 2024 08:34:44 +0800 Subject: [PATCH 058/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=99=90=E5=88=B61=E5=A4=A9=E4=B8=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/service/impl/AlarmSaveServiceImpl.java | 54 ++++++++++++++-------- .../alarm/show/service/AlarmHandleService.java | 4 ++ .../show/service/impl/AlarmHandleServiceImpl.java | 18 ++++++++ .../alarm/show/service/impl/AlarmServiceImpl.java | 8 ++-- .../bigmodel/interactive/vo/RemoteParamVO.java | 2 +- 5 files changed, 62 insertions(+), 24 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index 15564c3..3bdfb4a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -6,6 +6,7 @@ import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; import com.hnac.hzims.message.entity.MessagePushRecordEntity; @@ -21,6 +22,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -35,6 +37,8 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { private final AlarmService alarmService; + private final AlarmHandleService handleService; + private final AlarmConfigService alarmConfigService; private final IStationClient stationClient; @@ -49,41 +53,55 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { @Override public Boolean save(List alarms) { // 步骤1.查询告警数据对应站点 - R> result = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + R> stations = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); + if(!stations.isSuccess() || CollectionUtil.isEmpty(stations.getData())){ log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); return false; } + // 步骤2.查询当天处理的告警 + List handlers = handleService.sameDayContent(); + // 步骤3.查询延后未完成的告警 + List delays = handleService.incompleteContent(); + // 步骤4.近5分钟内告警 Set keys = stringRedisTemplate.keys("hzims:queue:filter:alarm" + "*"); - // 步骤2.遍历保存告警数据 + // 步骤5.遍历保存告警数据 alarms.forEach(alarm->{ - List stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(stations)){ + // 未匹配到站点 + Optional optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst(); + if(!optional.isPresent()){ return; } - // 根据最近5分钟的数据,做去重 + // 告警已处理 + if(handlers.contains(alarm.getAlarmContext())){ + return; + } + // 告警已延后处理 + if(delays.contains(alarm.getAlarmContext())){ + return; + } + // 近5分钟内告警重复 for (String key : keys) { String value = stringRedisTemplate.opsForValue().get(key); - if (value.equals(stations.get(0).getName()+alarm.getAlarmContext())){ + if (value.equals(optional.get().getName()+alarm.getAlarmContext())){ return; } } - // fpd告警拼接 + // fpd告警拼接站点名称 if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){ - alarm.setAlarmContext(stations.get(0).getName() + "." + alarm.getAlarmContext()); + alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext()); } - // 步骤3.站点参数设置 - alarm.setCreateDept(stations.get(0).getCreateDept()); - alarm.setStationName(stations.get(0).getName()); - alarm.setTenantId(stations.get(0).getTenantId()); + // 站点参数设置 + alarm.setCreateDept(optional.get().getCreateDept()); + alarm.setStationName(optional.get().getName()); + alarm.setTenantId(optional.get().getTenantId()); alarm.setStatus(0); - // 步骤4.根据站点查询配置标识 + // 根据站点查询配置标识 AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); if(ObjectUtil.isEmpty(mark)){ log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId()); return; } - // 步骤5.告警处理标识赋值 + // 告警处理标识赋值 alarm.setIsRightTabulation(mark.getIsRightTabulation()); alarm.setIsBroadcast(mark.getIsBroadcast()); alarm.setIsMask(mark.getIsMask()); @@ -92,16 +110,16 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { alarm.setIsSmallBell(mark.getIsSmallBell()); alarm.setIsShortMessage(mark.getIsShortMessage()); alarm.setIsWxMessage(mark.getIsWxMessage()); - // 步骤6.保存当日告警数据 + // 保存告警 boolean isSave = alarmService.save(alarm); if(!isSave){ log.error("alarm_save_fail : {}",alarm.getAlarmId()); return; } String key="hzims:queue:filter:alarm"+alarm.getAlarmId(); - stringRedisTemplate.opsForValue().set(key,stations.get(0).getName()+alarm.getAlarmContext()); + stringRedisTemplate.opsForValue().set(key,optional.get().getName()+alarm.getAlarmContext()); stringRedisTemplate.expire(key,5, TimeUnit.MINUTES); - // 步骤7.发生数据至redis告警队列 + // 发送告警数据进行消息推送队列 stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); }); return true; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java index e196455..f4af51c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java @@ -25,4 +25,8 @@ public interface AlarmHandleService extends BaseService { List handleUser(); List handles(); + + List sameDayContent(); + + List incompleteContent(); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 7fd7cb4..b53128a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -170,4 +170,22 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl sameDayContent() { + return null; + } + + /** + * 查询未到延后期限告警的内容 + * @return + */ + @Override + public List incompleteContent() { + return null; + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 2b769ec..1e3838e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -3,15 +3,15 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.source.service.MessageService; -import com.hnac.hzims.alarm.config.vo.AlarmCountVo; -import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -20,10 +20,8 @@ import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java index 3bcf351..f9661f6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java @@ -21,7 +21,7 @@ public class RemoteParamVO implements Serializable { private String remoteName; @JSONField(name = "device_id") - private String deviceCode; + private String deviceId; @JSONField(name = "device_name") private String deviceName; From 135011776156ea2c4937dacb6e69242eba0e384f Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 14 May 2024 11:01:12 +0800 Subject: [PATCH 059/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=96=87=E4=BB=B6=E7=9A=84=E8=B6=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=9C=89=E5=A4=9A=E4=B8=AA=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RehearsalRecordServiceImpl.java | 5 ++++- .../java/com/hnac/hzims/safeproduct/utils/BaseUtil.java | 14 ++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java index 55aaf12..2b9b50c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java @@ -161,7 +161,10 @@ public class RehearsalRecordServiceImpl extends ServiceImpl iterator = p.getRuns().iterator(); - while (iterator.hasNext()) { - XWPFRun r = iterator.next(); - String text = r.getText(0); + for (int index = 0; index < p.getRuns().size(); index++) { + XWPFRun run = p.getRuns().get(index); + String text = run.getText(0); if (findText.equals(text)) { - r.setText("", 0); // 清除原有文本 - XWPFParagraph paragraph = r.getParagraph(); + run.setText("", 0); // 清除原有文本 + XWPFParagraph paragraph = run.getParagraph(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String name = jsonObject.getString("name"); String url = jsonObject.getString("url"); - url = URLEncoder.encode(url, "UTF-8"); String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId(); CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); cLink.setId(id); @@ -148,7 +146,7 @@ public class BaseUtil { CTR ctr = CTR.Factory.newInstance(); ctr.setTArray(new CTText[]{ctText}); cLink.setRArray(new CTR[]{ctr}); - if (i Date: Tue, 14 May 2024 11:51:54 +0800 Subject: [PATCH 060/151] =?UTF-8?q?fix:=20=E8=B6=85=E9=93=BE=E6=8E=A5url?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=BC=E5=BC=8F=E5=8C=96=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index 1340d78..7a4cbca 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -138,7 +138,12 @@ public class BaseUtil { JSONObject jsonObject = jsonArray.getJSONObject(i); String name = jsonObject.getString("name"); String url = jsonObject.getString("url"); - String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId(); + // url编码格式化 + String encodeName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20"); + String prefixString = url.substring(0, url.lastIndexOf("/") + 1); + String encodeUrl = prefixString + encodeName; + String id = paragraph.getDocument().getPackagePart().addExternalRelationship(encodeUrl, + XWPFRelation.HYPERLINK.getRelation()).getId(); CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); cLink.setId(id); CTText ctText = CTText.Factory.newInstance(); From ecd2ed1a7c4babc57616860e13bd435af747de04 Mon Sep 17 00:00:00 2001 From: liwen Date: Thu, 16 May 2024 10:55:42 +0800 Subject: [PATCH 061/151] =?UTF-8?q?update:=20=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 56 +++++++++++----------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index 7a4cbca..3c84c29 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -119,14 +119,13 @@ public class BaseUtil { XWPFDocument xwpfDocument = null; try { xwpfDocument = WordExportUtil.exportWord07(templatePath, params); - if (StringUtils.isNotEmpty(findName)) { + if (findName != null && !findName.isEmpty()) { String findText = params.get(findName).toString(); - if (StringUtils.isNotEmpty(findText)) { + if (findText != null && !findText.isEmpty()) { JSONArray jsonArray = new JSONArray(findText); for (XWPFTable table : xwpfDocument.getTables()) { - for (int row = 0; row < table.getNumberOfRows(); row++) { - for (int col = 0; col < table.getRow(row).getTableCells().size(); col++) { - XWPFTableCell cell = table.getRow(row).getCell(col); + for (XWPFTableRow row : table.getRows()) { + for (XWPFTableCell cell : row.getTableCells()) { for (XWPFParagraph p : cell.getParagraphs()) { for (int index = 0; index < p.getRuns().size(); index++) { XWPFRun run = p.getRuns().get(index); @@ -134,27 +133,7 @@ public class BaseUtil { if (findText.equals(text)) { run.setText("", 0); // 清除原有文本 XWPFParagraph paragraph = run.getParagraph(); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jsonObject = jsonArray.getJSONObject(i); - String name = jsonObject.getString("name"); - String url = jsonObject.getString("url"); - // url编码格式化 - String encodeName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20"); - String prefixString = url.substring(0, url.lastIndexOf("/") + 1); - String encodeUrl = prefixString + encodeName; - String id = paragraph.getDocument().getPackagePart().addExternalRelationship(encodeUrl, - XWPFRelation.HYPERLINK.getRelation()).getId(); - CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); - cLink.setId(id); - CTText ctText = CTText.Factory.newInstance(); - ctText.setStringValue(name); - CTR ctr = CTR.Factory.newInstance(); - ctr.setTArray(new CTText[]{ctText}); - cLink.setRArray(new CTR[]{ctr}); - if (i < jsonArray.length() - 1) { - paragraph.createRun().addBreak(); - } - } + insertJsonArrayIntoParagraph(jsonArray, paragraph); } } } @@ -167,12 +146,35 @@ public class BaseUtil { formatHygieneRecordTable(xwpfDocument); } } catch (Exception e) { - log.error("数据写入异常: {}",e.getCause().toString()+ e.getStackTrace()); e.printStackTrace(); } return xwpfDocument; } + + private static void insertJsonArrayIntoParagraph(JSONArray jsonArray, XWPFParagraph paragraph) throws IOException { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + String name = jsonObject.getString("name"); + String url = jsonObject.getString("url"); + // URL编码格式化 + String encodeName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20"); + String prefixString = url.substring(0, url.lastIndexOf("/") + 1); + String encodeUrl = prefixString + encodeName; + String id = paragraph.getDocument().getPackagePart().addExternalRelationship(encodeUrl, + XWPFRelation.HYPERLINK.getRelation()).getId(); + CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); + cLink.setId(id); + CTText ctText = CTText.Factory.newInstance(); + ctText.setStringValue(name); + CTR ctr = CTR.Factory.newInstance(); + ctr.setTArray(new CTText[]{ctText}); + cLink.setRArray(new CTR[]{ctr}); + if (i < jsonArray.length() - 1) { + paragraph.createRun().addBreak(); + } + } + } /** * 卫生自查表格式处理 * @param xwpfDocument word文件类 From 1d74620316fef3b2346c1e33b189a29ad54a19cd Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 20 May 2024 16:00:36 +0800 Subject: [PATCH 062/151] =?UTF-8?q?update:=20=E8=80=83=E8=AF=95=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=B7=BB=E5=8A=A0=E5=8F=8A=E6=A0=BC=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java | 9 ++++++++- .../main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java | 8 +++++--- .../hzims/safeproduct/service/impl/TestScoreServiceImpl.java | 5 +++-- hzims-service/safeproduct/src/main/resources/db/2.0.1.sql | 6 +++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java index 17e5119..27ae3d7 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java @@ -9,6 +9,8 @@ import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.Date; @@ -59,6 +61,12 @@ public class TestEntity extends BaseEntity { private Date testEndTime; @NotNull + @Min(value = 0, message = "及格分必须大于等于0") + @Max(value = 100, message = "及格分必须小于等于100") + @ApiModelProperty("及格分") + private Integer passingScore; + + @NotNull @Size(max = 255, message = "考试地点字段长度不能超过255") @ApiModelProperty("考试地点") private String location; @@ -77,7 +85,6 @@ public class TestEntity extends BaseEntity { @ApiModelProperty("参考人员") private String peopleName; - @Size(max = 1000, message = "考试图片字段长度不能超过1000") @ApiModelProperty("考试图片") private String imgPath; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java index 518ebb5..7d89726 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java @@ -13,12 +13,14 @@ import lombok.Data; public class TestScoreSumVO { @ApiModelProperty("应考人数") - private Integer peopleNum=0; + private Integer peopleNum = 0; @ApiModelProperty("实考人数") - private Integer actualPeopleNum=0; + private Integer actualPeopleNum = 0; @ApiModelProperty("及格率") - private Double percentage=0.0; + private Double percentage = 0.0; + @ApiModelProperty("及格分") + private Integer passingScore; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java index 6145b38..ca24f67 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java @@ -126,6 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl s.getScore() != null).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { testScoreSumVO.setActualPeopleNum(list.size()); - List passCollect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList()); + List passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) { double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue(); testScoreSumVO.setPercentage(result); - }else { + } else { testScoreSumVO.setPercentage(0.0); } } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index b1296e1..3730612 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -40,4 +40,8 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='卫生自查模板详情表'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='卫生自查模板详情表'; + +-- 添加考试及格分字段 +ALTER TABLE hzims_test + ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分'; \ No newline at end of file From e3c3a4edbc11f5fd467dfacf077717457f655a96 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 20 May 2024 16:55:37 +0800 Subject: [PATCH 063/151] =?UTF-8?q?update:=20=E5=9F=B9=E8=AE=AD=E3=80=81?= =?UTF-8?q?=E6=BC=94=E7=BB=83=E7=9A=84=E6=9C=88=E5=BA=A6=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=82=B9=E5=87=BB=E6=9F=A5=E7=9C=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/safeproduct/controller/RehearsalController.java | 3 ++- .../java/com/hnac/hzims/safeproduct/controller/TrainController.java | 3 ++- .../main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml | 3 +++ .../hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java | 6 +++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java index ae78443..14cdc89 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -82,7 +82,8 @@ public class RehearsalController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "rehearsalStatus", value = "演练状态", dataType = "query", paramType = "string") }) @ApiOperation(value = "演练计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index 57ef4ba..7eda44c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -91,7 +91,8 @@ public class TrainController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "trainStatus", value = "培训计划状态", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml index a9ca3f6..19ef188 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml @@ -87,6 +87,9 @@ AND scheduled_end_time <= #{param.endTime} + + AND train_status = #{param.trainStatus} + ORDER BY create_time DESC diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index 1714714..9cd63ef 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -275,7 +275,8 @@ public class RehearsalPlanServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); String startTime = String.valueOf(param.get("scheduledStartTime")); - String endTime = String.valueOf((param.get("scheduledEndTime"))); + String endTime = String.valueOf(param.get("scheduledEndTime")); + String rehearsalStatus = String.valueOf(param.get("rehearsalStatus")); if (!unit.equals("null") && !unit.equals("")) { queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit); } @@ -285,6 +286,9 @@ public class RehearsalPlanServiceImpl extends ServiceImpl Date: Tue, 21 May 2024 21:44:04 +0800 Subject: [PATCH 064/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=96=87=E4=BB=B6=E6=97=A0=E5=9B=BE=E7=89=87=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/vo/RehearsalRecordDetailImgVO.java | 16 ++++++++ .../safeproduct/vo/RehearsalRecordDetailStrVO.java | 15 +++++++ .../safeproduct/vo/RehearsalRecordDetailVO.java | 3 -- .../service/impl/RehearsalRecordServiceImpl.java | 43 ++++++++++++--------- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 33 ++++++++++++++++ .../main/resources/template/演练记录表.docx | Bin 12341 -> 12368 bytes 6 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java new file mode 100644 index 0000000..abb312d --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "演练记录表VO类") +public class RehearsalRecordDetailImgVO extends RehearsalRecordDetailVO{ + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java new file mode 100644 index 0000000..2a7c8bf --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "演练记录表VO类") +public class RehearsalRecordDetailStrVO extends RehearsalRecordDetailVO{ + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java index e1d414f..545065f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java @@ -55,9 +55,6 @@ public class RehearsalRecordDetailVO { @ApiModelProperty("演练科目") private String subject; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java index 2b9b50c..4018a62 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java @@ -19,10 +19,13 @@ import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.TimeUtils; +import com.hnac.hzims.safeproduct.vo.RehearsalRecordDetailImgVO; +import com.hnac.hzims.safeproduct.vo.RehearsalRecordDetailStrVO; import com.hnac.hzims.safeproduct.vo.RehearsalRecordDetailVO; import com.hnac.hzims.safeproduct.vo.RehearsalRecordlVO; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.support.Query; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -150,23 +153,6 @@ public class RehearsalRecordServiceImpl extends ServiceImpl list = new ArrayList<>(); - if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) { - String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(","); - for (String img : imgArr) { - ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + - BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); - list.add(imageEntity); - } - } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - ImageEntity imageEntity = new ImageEntity(); - // 设置空字符串,防止空指针报错 - imageEntity.setUrl(""); - list.add(imageEntity); - } - rehearsalRecordDetailVO.setImages(list); // 记录:换行符使用\r\n String standardRecord = rehearsalRecordDetailVO.getRecord().replaceAll("\n", "\r\n"); rehearsalRecordDetailVO.setRecord(standardRecord); @@ -186,7 +172,28 @@ public class RehearsalRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(rehearsalRecordDetailVO); + // 图片 + Map params; + if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) { + List list = new ArrayList<>(); + RehearsalRecordDetailImgVO imgVO = new RehearsalRecordDetailImgVO(); + BeanUtils.copyProperties(rehearsalRecordDetailVO, imgVO); + String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(","); + for (String img : imgArr) { + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); + list.add(imageEntity); + } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); + } else { + List list = new ArrayList<>(); + list.add(""); + RehearsalRecordDetailStrVO strVO = new RehearsalRecordDetailStrVO(); + BeanUtils.copyProperties(rehearsalRecordDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); + } String templateFile = "template/演练记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/演练记录表" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/演练记录表" + SafeProductConstant.PDF_SUFFIX; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index 3c84c29..da74c7f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -119,6 +119,7 @@ public class BaseUtil { XWPFDocument xwpfDocument = null; try { xwpfDocument = WordExportUtil.exportWord07(templatePath, params); + // 超链接处理 if (findName != null && !findName.isEmpty()) { String findText = params.get(findName).toString(); if (findText != null && !findText.isEmpty()) { @@ -142,6 +143,7 @@ public class BaseUtil { } } } + // 表格处理 if (templatePath.equals("template/卫生自查表.docx")) { formatHygieneRecordTable(xwpfDocument); } @@ -151,6 +153,36 @@ public class BaseUtil { return xwpfDocument; } + /** + * 车辆检查表格式处理 + * @param xwpfDocument word文件类 + */ + private static void formatCarCheckRecordTable(XWPFDocument xwpfDocument) { + // 获取文档中所有的表格 + List tableList = xwpfDocument.getTables(); + if (tableList.size() > 0) { + // 循环表格 + for (XWPFTable table : tableList) { + // 获取表格所有行数 + List rows = table.getRows(); + // 第五行到倒数第三行为需合并区域 + for (int row = 5; row < rows.size() - 2;) { + XWPFTableCell startCell = rows.get(row).getCell(0); + String startText = startCell.getText(); + int index = row + 1; + for (; index < rows.size(); index++) { + XWPFTableCell endCell = rows.get(index).getCell(0); + String endText = endCell.getText(); + if (!startText.equals(endText)) { + break; + } + } + mergeCellsVertically(table, 0, row, index - 1); + row = index; + } + } + } + } private static void insertJsonArrayIntoParagraph(JSONArray jsonArray, XWPFParagraph paragraph) throws IOException { for (int i = 0; i < jsonArray.length(); i++) { @@ -175,6 +207,7 @@ public class BaseUtil { } } } + /** * 卫生自查表格式处理 * @param xwpfDocument word文件类 diff --git a/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx b/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx index c83a99c9bb39ebd1d1ae7ced45cd96bb4028312e..38209f5d8c5c03de5ceb57815dc08da24b9aaf6b 100644 GIT binary patch delta 5126 zcmZ9QWmwdGv&U&%y1Tm@0cq)GLApaix|_d%ES*b82olmEwSXYHAT8an#DW4M-Oai0 z^Wu4~bLRJEUd&uG*UY^5eLrosleX#NAo#Gyx-%*YN=Swr6<{!`+b2ZS&3ZxzK1?8; zIsa4-2A#kAXkZwsoYUgLN3zn4|K^DyuJpNO=fTgRt&>#b<6_$sr8#Gt`HztNeqx>y zw`ziYAfHlrYM0m$4_BCn z^dWjHcIj0ZH*gG2njpyL6dN7DNMkTc39uJ{oGke~{(f>ZcbnSr^O_re_Z^RCUwc%x zIaf}%V17ABL4dFB29hE z;D1*D{fWv27$|@t{_%jH|-3a>F&ih^xSmdnTvcMb=8Ajjvi>T)+q z6{ZEYDinB+bRbPzy!t=c;UzI0RrU6AS%C@oTY~NYNRs^*9q+NW(1bT`@|c3Mtids= ztF^}*D#oCG6xsoO1*l)%n$WmYUeJFe%24B*I8rA9p#MTB0e>| z7wh_ZR79h-`bdubYCAgUK*TdDgb0k{*cBM|+s8jbw767+{g0Wpi}s*jrqfnZa{3P4 zk=29I14W0!9PIu!{OLB>O|}m#ot7vik6UJ;PGqtIzp$Y0tzLWZ`r=bKEk*yDTS~Vb zJIe#Wbz3?FYxsqm2F{%{XRZI=@rLR36+qR|d7d%vN3<~BxU@q<(K&z(`X7#=^#%&z zcrqn4tCw$bqbmn-1frbX>z6|(HOn`+@JyW-OokuI)r6OESMifN1vuvsmBcB1&nLg@5!_2sgXq)T)W}Hox@d3NoU+(=rL`yfk;Tv9{o4>PAUSOb5+{}%V+)S$ z#*rx8LYqn4eoej27Rm8Tg4zGe{7vo>_P1 zF(Es^Y1-qHH%+iup`oX~tgtK zX${O9{|%r0TkWVNQrDoYEBV%qS+ow>h&TsC_<~f{bd+-(bWF0q5xY__deb%Z$zO3D^@kbtA)6)(4OJFyk=_8;CQcAKBZi4Zeyys-W!Ey(50A26 zH}yr9dxP{T`+{6sl?Z{F#cBN&_8SvZ>=vXfx4?q_ba+)j$tg+ur)BL zcA#c-kcNWQxp9iDN%6$=Pm-CZ&A$LCJ{<3QY_`V zY(o=FaQROM3U_9)3=^*O;c1x_HVLz0aQBQY40U|o(-@xSteQe(Ut9V)CQBdRi{Sxp zIH6jC$$iT56LNdg4^C>8b@iK(<)#xiyVo&^U6+ZnEsi;u8Pn}&KCNI0^8|1{>-(Ea zs2@y3lLxv9w#dd5{Yl!4VwkK=n6F&=mZe}uB7e_gI4i$&mE>N#LUM^4G8bsiVFaRZ z=N9HSG$z(OyjCMPb8q_O_Mjk!SCC0rsW+L}o&|M#DPa-OSHiWgyI#zU6Z-+s-6^N{!ishq?n4KPtq(|p$C8I@U`pPKZh z=Ovod_{VnMH?pETEbJ5tvE_qFGs&yP){dbWb`+ zPhK&HOB>lt`uIJjosJ1n{>T6uJWYpE!}Zx0rN1#AS`3U7y%)}(;07!s%*eO(QZ6pb zYAh=n?P$XL4L+pqu#aKv8>ggwVvf_>yiG6n|e%^X;r|NbqP{|zBK zc5pMgu)6B&ysjpFwElbG=8_}}Wp^t*?SVrvJnIBM>NuK=v0mkgZ7}EF19_40%X{t}{f+2{@W zHPSmr-wt_Y_*e=)Lv-|~Zs`y;gJl(LT+bdN*H0k143bb#Gv~=iOwiYA+4#MJ3r!2E zU>6~e;Z#z5x{0DTrUuz2dQKN5qO3|Qr^)s^pIw{VZ3qYU1CYbh(X^r_;4AoAhO%EE zUy?swJ{~=6GSf|v3Zr4G%{3`}h2S7(?PSw-V`ud-h z2GT)(5p)U2i`Jq0djSkPGVGR)PwTgy8;i*DPjV3xX(hl4(fY|P^y5!1OT!r!Z;6(S z5UI$VvEiS~x`6T6A0lU74IgLEwH)uxmMP7{iY$ri#P87PLe?bvxwosHm{oY9&tp~* zD6b`#hPtU(ng!;XrE&_OYxznr1LWB0pQ=%r#`ybZUKQQVusCtEvB?3t({6Ld-=A$; zAPtFgr5T&YaxyU+sDV#>DZOjlvUeGfi9}z@)y)~)c;NVOt2bHCpmC$=qWJ(4q)JmE z1jRiQf4MC=QL8rkCT4&_RGNWW82`!Onuq(T?zwJ?6g$=vp7A3*0YuU9H^#0i^}7+H zu2_3XCnrsJC$HR*@)>PDP>P9<-;;P*#=oyH%(V_L^-6{GP$VbFYBbVrE`DJ$(%>>d z;Om)Ykdn9%EfVfQ1jWLkd3eP=zt*0xp&1x7&}42<3lTXO3v`vMP8bD3L8*eip``&< zJZT3nzA8LLEe0i&D}zOddAuD5h0`%qe~YE{drPrNtgV{u6SU=kP+bd{K>18U(})c+ z55~mv;bEop-i!~8O>B39q2rc0UB3)i7GN(Mw^cURwtcq||GaDyuQ1QoX^@P*dzg_; zy&3u5O5NY<2iV2<*n$bHPV+~?IyJk%nd{1OWyZzceDiP#ef+XWY!d;~!m=!Ae> zuej?lw&quUYyNJ0ALY*H97@!JTSs~$=U9>TcAwGevEND44+dPzwOYCDIhn4|Kq9s9 zUD&CKBBwLa4W7;^k+Xchx7jw`?WvN*((Nzl$&* zeJ|~cTOxR=4U~U;#ukRT+Mq@!Pi@+iP@!Pd z_yOxxEVX31PcE&YgFHFR4egtu6_$d*#7m}ym(TGskr?AGZGo%bvRh-bzJ4EiGge)# zf-5eha@U1UGU+I(*eaSVdDcLrn;EzzX`K?|GIvSNssXl%_==M@z-UH3;b}#7bjQa= zPq|I8K%3ps16D+9f<*;Et?B82E^l5>i|>rc+6NRGcBS#m!G(vzS=`kXwva~}TM}=x zDJoq5v!P4N_d$r}ywSI3@z0SWUuIx5!SXoq_z`oCN&*KbrR#xI*y$7xFZ^#~daa}* zfBFBRRk_P4erj6WF=`reJq|)h49n4Ox)0zk`2{x{OV0+Zvyd?UFn_%O$eJ0q(Hys0 zqYGCTXcci16`y>C{7J_8H3WqZjbi9D#_CcwRTDl1y~q9PAX?BSE|v20plw@Kbmy|J zo%SMhe8nPIkKpCinD`jtS>u|qe;jLP-8N zImy5+$3_rC_Q^4RzLPF3Fs4)94`+l7-GBgSruyXb&4#_C6*LPE6&;xUp+(AAC;|P} zP$2r|-zagm0B>o=g^0my!Sc=kUr{@pmpyFl;)3ey{iv09i(UIK9vsP@SFMT7DpyyK zY;>bZ)nB>GZk*KmXelyQQ1>Wb;ly5LOCu^K9WdK1eC-Ps)c3>4$*8a}e zm8=_;M`IGYC!h&Tws;I^@G8*b?L# zXU~Oq$Rjixg0Z0JYbq=&Q97$rjaS7ox5z(V35yxl$TRmvswQUI#S4le?fabgW`@{C zU-kX`tQ~M9)$+5SDniQct^L+7qzUKKtzWGOO_WCp106txIt8QnWW&njdzDuO_D3k2 z505%3RdkG#a4p!kgUAG~5W^f&WyleoMExO(K7zsvsp=7{WmctJR_EtAK$y^FVer13vIv^K?k{6LT|K~WVxC6PJfh7t`?~}(J5pw2*%cF=t}2Eo zn-A>YQ0%=_X6rR$LW@tW_Yq}p2ODR@gL*Sj?59mBb8xV@9?F|TeXsjZnVDjkGWOpSI4$P=pJccxNp;xm)O0Amh!0z@86jjh3nmJl3~~);Yt6A_2eX z)L)Q7q}f09l6r4WN~$AesbSx#YoaIoezzt0+3@jP-kT@9m=AC*>gAG8lxQuM%ZWwQ zBd;CIl}5l7%005@^hL~{49rbndNX}ar?{+x+TAEW3dhI^+S3&cJBxenPJRgziu{PH z10+Bk1qr!sH(?>HgUNJVp9NTQmsn(Zm2@ffa!}EQpT{D8(U97_8n|X*J>%#--I-U? zpW|8(XngNywr4+RBP$tt9ikfivpUJ{bgtE=f8!H;v^p!V)75a9`{j$bj#=>?USK&} ztCm>$!Lfq$t1giPrflwjNV})_qQN6Z1^~F7I;ni(?iC$-ybvoud&WSzDJcpxy*s2Y z=j1ZoRHUb%aoQbrx0UwH+@JJ06ZNGWWk=zk$}%$*lf@pxF*~mGHQ2}-mcwRpDb|dH zz4hUcaaQ`W^gXeTjGp28VHFy7CEDxIgYWLw62k3_E^S7xm_5SX-KbJwk*~dU3cPXY zcjqbti|u!-c|Bxy>UPwu%PB5Eln+`OaPxcjP(rn} zvexOnSoS9^L+TW?5wzSM9qq*~zE^EkcD)@{NnKT(e}6=2Q{3pP7IC`INa{rTRch3v zS~7?9a3?bA&YI>SYHHCSvF&^MK%ciQY)|XRc~bS+qH)2;Kw`04{Ld@QZ6*E|kY0gz zoS3{eEf%KY041)5f@$K6kxG5U*TUJS;cf}bGJdMT#=s1Ev@k^GY9#(X#~%oDbPvI|K+H zIdi|W6K_x=)4)~VdfIuAtE53AGfWUE<;K#gHvG(M8e;@Ib zkioZi*d=|`X~$iiZ34R9nCm)>1nse1=}^ooT6{Ze;!Cm)L`{MgP)(l9=-@kW&F%O> ziGhV~u#=gkDl{3ck>&As`jhy6z5K6D1F-Mpgx<&*QYIvvKJ5iXgp<|{_*K_c4!3iKpx8oOSa10LZQ_3btemxZ delta 5085 zcmZ8lXD}QL*R`x3C9K{edaq&C1ks{L?}X^RWQEv8^v)uBiPedyk6we-g2)Q1TQz!# zUf$>V-XG6=@1OhQ&Ye4V&YZb(&Y84nvPphM7&$5cvH@UW`K8Fy!cuxY`h>|}9;RQD z=^e!6z2H_JjE?lFG-FqkdOB(vjr!K?_HpHKSKLsowsU`M1XIRT-y-4f1+a@qJr$1e zrVUxI1f7VJK?bC=BSZZ)Gpda!Hdjg9S_+fM?CsLU!RW%thzOA!ItfPERnF)7h z*W-Fwky1kAgcTS)n3o9;)Z>M8+8bE~FaIYR+-!^Zk(O(FYxfLhyh|r@6Kkb%!W_8b zZ4RW{L2>#+B|anyof;B*zzj~HKh7MVzF92cZ@g6FG2w&TJTu=yWKQyZiDY{(7u`Ei zP2=aAFH#hxjA%Xsve|dOJuJD_Z&XJvP)@T|36T3qqRG1UVA?b;sFR0-hisgVPA`;^ z*pkSi0=~SdizV^*+}hj&$@vvbS%y;TVAlgU3qdDe4gaNgeU_@avo4i1SX>>Sp`M`v z9&HfGf0MhZ5f-Wb?V=4AD$%!y4tiA5?Yb;@ho`H70|a4VVG&?OX|KKLRx|~@{u}%E z*jQMP|L(%k09M$K*QV;cfZwsN)Ig!Lrss`K(RoM-tsv}o{Bz!&`5)P}l*rZihaPUm z|8h*7)86W(uGWuGf1E%-)Dx}9+n_zw@58LEw<0Th9D!Q+Rbq)rjiZ5e;W1K*_R`CKTJT-K>aXYe zOvYWq^BZ%`O}}AwicykkZK*|F!y(Yp`kLW zJV9@(?9$mgXj%T5LFpAAfLjCMG%sQs8kDR+Vl(uPYs1?wxFNTgpYvE*%}H%YgQDS> zgKb@^m&@1)(hXoXjTk2_IE+gAYjB$7*(tL1G%nDO5BJ1nxgE+E3|?$~(4vVFai7+r z%X{=A56g6VxzFfXP}&rbY_$2hm4A-r|HC}>RWTT@jl)Y|J9p#o{A8*W9)iOO!ycaK_C!PmIH;m<2khVKS!8 zaS*b1m!;wR*E!_!mbK)m3JFO=9k7Uq=oelA zDg+k`tB(Y3LB;{o`MN<&s*eV^WuJv3NDz6`lD5RU$s9@SLmb`r)gJ(&EmC>sgmueH zkS4zFnZ_i2%G66Dju~|Hqk%vz${)9l6eq@eGpQ+RvGHD(rh6KFJ@~z-jLk|^ z#@!bQ0`Ga=_fWp*t@x%7C3f8dbK&MhSE`pRlBevT1*c*|9@7$|Au~KW)+GhE* z>a$kN48KtU35}mnKoo_Dc$9mmUBg20r1M3>(P}V=$oKF`$9U&yrvi?U7-!MRm*9o) z@Ju{eC(U7c8cm^Nmm=k*>{DGk;q;bp3TT@6-77>Xp+g)a*9#X@rsw5s8WkgSOV-5d z)=xyoJ{P+^lKcSs`>N&2I~ET?c^cU%Wq;dy*3^PFT|UiblQp2vQ~(%P2w_uW>bt?= zw+@TRSNW2STM8ypWD{d$@!YMqiF~g}Z4;X^Yz0>X>Av;7R?+XQ$$YKfXdYHD4CIm- z_=-*(FR$zg6W}N{9C1+`V0u8>778@`)v!cII_n>=oe>5eXZZMNZ97zXf18SZ(y7*32`AzkiiQX7j>dK;0FHCLGJmP7?CH0|lk@fNN5$M{c`haL#jgVDB zKvx8X@zx_VQF}5(Cl1kakKD9Ce8VnJKJ)TLx86+WxB)Ank*+6^tbl!NCe=zH|5?6* zUW?Tvjp*hM7m^}E#KOOiCEzFnCp_opa{sl-fv+eVZ6z>n>!Lq+)C5H-rgAC;i>MOX z?Yph0gGyD8zP+X|?KS2{9S4~G(CqO+UFy=;Kd^Vf?Avp=6uO`9Pky-i+8&hccKBIH z=wj-23L7P-iF_S?oLtSLoPM16%4VFfoiidW zcLT@4LV-6o(DlLqbSN-?%i^j5M#|n5n>(48%a*tw#qBr96wUHPJO|8#bR)+*FU$%p z>tYpuhnKj_`q4s&V44uC%DoQ=3dGQ@x6_4KOKY+aRjt8_Yh!#@wtO6;u8uh!44 zVISyheNWowKNiW?nxnh42IIp{!t#mbk2NH=viKP?B5Wr%TPmO%0Vf$xOhUH39^EwY zNDO2kol}o69xVGPc>46|30sHH3EGS>t|mXQMr!DkJ~*xa)tFfuuTh*)Y(M+}7{)by z*C0-GGjx`wL}HDNI&T>mk|bWGNg@_IQfm-bof$oU6X=Mr^$=|phOv;_C!Tgd9jYb1 zBi}gi$*5@dcZ1~FE1y@9xCk5A9!=PwSaLIMLffTiBd-Z8##hyR&9j3Ly<)AKr-|a- zC0D9ulRs9JN*O(DUDZ{tNR51h#Lt>+G}G8SJ!05);|;iq%w9>#+A6;)RIvG6#n3f* zME6$o!|i3@1IynJIt7QOfsM)x55|cOXbB_4!m5P*R~tY)ee8woJ?;G6-+K572DrQJ zGg*4htDM}0+~bEHHnW>&FctZvNITOP3WQ0!v&2y~rOqZ>gjr;H193Wcnb4mFNPGWa zNOx8P$)c9@(NUkHeyYQ?+_)ar9L_&JWo&&XS*-`()j^-$Squq0XIHNX}`whB(Z1;~sjTn+qo3{RwD za3V7NgLYOkObcbAlWY}1UFdtab8gF^?6LU&@IUequJ zA)*><5SxT~AfFhMXfEMPr^XDR6fBl;uL`{=4w;=a(!%y}PNKPM?gtk(ZvQHpW&wGi zkJ-vJtcB3cx3`OL3XBKX%chpSm!I6YMHkcQ*iWnuTkPxp3Wlo%lKZCTUBK+kP;Ncb zfh0c>c%Ni-gyk_o3Da~~_7m{$$kA}k+6Zl$iVCs^NG5R&Tjn@An^9%++|0K)%Qt9d zJ|R$UYhR#)OQvXkGuzQ4+}M*(Ufm8&e*I?eZh=samAPreVRvO=m zC9n&o+?Gii4Y-unA}&kVgmIp%t?aYDg7z&JvQu;iTyi&IQ}GpYKGFluD93)2}Q7 zg1@{V-NiA71l+nTyrw0vwv$gH*GZh1r(WCkStn=gybq>y3+O4_f`!m`Ru&NZ6YS#V z?`TB5{OSLpa!~6QN~AsCCT24CUgM8JBN>~19*AN+UOq-b=HyVD{azJvHanBn6L+w; z;sv}v>%6+=kuSO*k!jzV+B%~zwF?qQm$A!&!GTB9PU`?te0=<&WvI{X(I~t>DSzSN zczeoN=l;%`l`EnV7Jj^HQ?d@Mq!vpKFdeb6;OlUOW?KK1@`+)CgCERvZHycZk7rB10f^k3 zCt2ifkG5|n61%Uib|jyVQ_radweG5~LU;hfuKJjW!uRC3xHFkT*pj;`tig#Ybb;X_ zY`9ix43tv}FgJPj0}plY)cgQ#Md9E%8qrOyY)e=ZD~7?Lg%>R^|vV=PU084J(hgTIGYmlGeZYS#vN zBk$tth!m225$^?-^>~NN#|N4*Ds0ZfmI4)K)29g*uwBShVvew-=x;(ngXl$IoaR?G z{v!iKP+eL|3320uaP4=V9`}WJZz1!+$0&@dwY`Cw%9rorH;&-FN0uW$NozXEvo`9D z&XBr748Q1o5`8#M_KOaW9`U9BXs-{>W|GjiqLp(v!F{sj_QkIyf-#%-_G~|i3l^Ac zD-Y^ahl$QGMo^KG{^E>vVBOu4gDN z5g&Tm90+B;=ScD#LN=N|{?x8G)woeTk-a}Ux`dr3B|U%8d7R}uQ(JZgdU2cy8p^t% z(V$&YfQE%}F#ohIvW+Yl!*0fK<}gWn+$Sy!oKu9PJB{%3x5?oz5}BTrog;e08g3Yq z3+;HX+Hp07SEXcrjAI+^y_(tyU0#-Jg*-2o-8Ao!kj(kyL;V$Q_}HK#w{O=B)K)Ub zV-B+-uE`{OD;^t}M^-+rV_y83G$qD^b8#HeE@0kf-q|I{>qEuEZ)ec1x8H4>--EG+ zO10fUiqX@CVq+5NCG(}C^tfrbg28c_jS$mv7rmiyLOmKXJ)M~toIL(>8M@&7Xe~#2B#jixMDH=VY9ks3R1qab{0|i>j?J&)| z-M3$NV?hdm-WLMc-Rv2rNzI}i2HFi{$FHQ3Z&nq4l<5t8!&APlJtq7;5G7rU=VFP_ zUQ{O<`t7qc@tUar5-8^1r{yoC=M@~IsJh*ja-)-fd$cta^)Tv`P$DXppmP*andtf< zEDOh(oGH_W#PPSiNpS`e$YSDu#nJmUzMOS z*TSsZ-)F1tr@1c?aw;2a3UZ=$g<5n@aziDOD<*r7k}OS#NeGnltQe6UOvo>v^s)-O zTYPZg)&223g)Gt?qy zcMCet>(_n>PWDw=*Zo8Lv4MMjrbNSa)(nOmC|O%CEa(=Ph@#v$_Lto=Y0T0J)H&>v z!JuN4p6NtYF{$>=zvHz@6Wr%xnQ=(EfU{m5{; z${pYp+n2;Z`j;*9%r3U-IbBG2dqsaFffs-j zI9N~=-~)FR1Osy52tgr+|5bMXF3^V`2+9M1Z~-9>hJS7OfA!zLQ}S?kA$dR}yjn;W bdmjY1Fx From 3bba4b39efa78f8afbabd3576f24af7727efdad0 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 21 May 2024 21:45:55 +0800 Subject: [PATCH 065/151] =?UTF-8?q?update:=20=E8=80=83=E8=AF=95=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=8F=8A=E6=A0=BC=E5=88=86=E8=AE=BE=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/entity/TestEntity.java | 10 +++++----- .../hzims/safeproduct/service/impl/TestScoreServiceImpl.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java index 27ae3d7..0235e18 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java @@ -60,11 +60,11 @@ public class TestEntity extends BaseEntity { @ApiModelProperty("考试结束时间") private Date testEndTime; - @NotNull - @Min(value = 0, message = "及格分必须大于等于0") - @Max(value = 100, message = "及格分必须小于等于100") - @ApiModelProperty("及格分") - private Integer passingScore; +// @NotNull +// @Min(value = 0, message = "及格分必须大于等于0") +// @Max(value = 100, message = "及格分必须小于等于100") +// @ApiModelProperty("及格分") +// private Integer passingScore; @NotNull @Size(max = 255, message = "考试地点字段长度不能超过255") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java index ca24f67..a075bb2 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java @@ -126,7 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl s.getScore() != null).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { testScoreSumVO.setActualPeopleNum(list.size()); - List passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList()); + List passCollect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) { double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue(); testScoreSumVO.setPercentage(result); From 31a420395eea82c9662ecfec370d7765eddd8218 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 23 May 2024 09:29:09 +0800 Subject: [PATCH 066/151] =?UTF-8?q?add:=E9=81=A5=E6=8E=A7=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/service/impl/AuthenticationService.java | 3 +++ .../src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java index f836450..f34088b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java @@ -102,6 +102,9 @@ public class AuthenticationService { // 如限制机器发送遥控指令 if(ctrlAuth.getIsLimitMachine().intValue() == 1) { SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); + Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); String machineCode = sessionContent.getMachineCode(); Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { throw new ServiceException("获取问题机器码失败,校验不通过!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java index 97dfe29..d3ea096 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -28,4 +28,6 @@ public class DataVO implements Serializable { /**实时数据结果集**/ private Map real; + private DataItemVO item; + } From 1ffb5ac98cf58515630a81109bfffc1da064b591 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 8 May 2024 21:53:27 +0800 Subject: [PATCH 067/151] =?UTF-8?q?fix:=E5=91=8A=E8=AD=A6-=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E6=8E=A8=E9=80=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 2453887..105bf73 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -148,7 +148,7 @@ public class MessageServiceImpl implements MessageService { } Long dept = station.getData().getCreateDept(); // 获取站点用户 - R> result = userClient.userListByDeptId(dept); + R> result = userClient.userList("200000",dept); if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { log.error("微信消息发送失败:用户获取失败 : {}",entity); return; From ba43d0ce58177ad21ce75df579886297faeb5915 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 9 May 2024 21:10:30 +0800 Subject: [PATCH 068/151] =?UTF-8?q?=E5=8D=87=E7=BA=A7=EF=BC=9Ablade-common?= =?UTF-8?q?=E5=88=B05.1.1.RELEASE.fix.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47b1aaa..1b8c1e0 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ org.springblade blade-common - 5.1.1.RELEASE.fix.1 + 5.1.1.RELEASE.fix.2 org.springblade From cc573a2bb0abc6a02040d3179702e41d77180c2f Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 10 May 2024 17:18:00 +0800 Subject: [PATCH 069/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=80=BC=E7=8F=AD?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=B7=A5=E4=BD=9C=E7=A5=A8=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index db48343..3f45160 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -1591,7 +1591,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl> operateTicketInfo = ticketInfoClient.getOperateTicketInfo(paramMap); From f59c5bccbced531254b29e799677941642d920a0 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 10 May 2024 20:07:33 +0800 Subject: [PATCH 070/151] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E7=9F=AD=E4=BF=A1=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java index b9483a3..0128e39 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java @@ -63,7 +63,7 @@ public interface AlarmConstants { List HZ3000_TYPES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12"); - String SMS_MESSAGE_TEMPLATE_CODE = "aliyun-alert-push"; + String SMS_MESSAGE_TEMPLATE_CODE = "aliyun-alarm-sms"; String FDP_INVALID_STATUS = "1.0"; From 3587efb3366e2e7e051c97024e9534d4f2304c76 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Mon, 13 May 2024 20:39:55 +0800 Subject: [PATCH 071/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E7=BB=9F=E8=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java | 4 ++-- .../report/service/impl/OperStationMonthReportServiceImpl.java | 2 +- .../ticket/twoTicket/service/impl/TicketProcessServiceImpl.java | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index a18d489..b1d3ab4 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -361,9 +361,9 @@ public class TaskServiceImpl extends BaseServiceImpl imp taskReportVO.setUserId(userId); taskReportVO.setHours(list.stream().mapToLong(TaskCountVO::getHours).sum()); //巡检任务完成情况 - String finishSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getFinishTask()).orElse(0)))).collect(Collectors.joining("\r\n")); + String finishSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat("完成数量:").concat(String.valueOf(Optional.ofNullable(vo.getFinishTask()).orElse(0)))).collect(Collectors.joining("\r\n")); //巡检任务未完成情况 - String undoSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat(":").concat(String.valueOf(Optional.ofNullable(vo.getUndoneTask()).orElse(0)))).collect(Collectors.joining("\r\n")); + String undoSituation = list.stream().filter(vo -> StringUtil.isNotBlank(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()))).map(vo -> DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, vo.getAutoVideo()).concat("未完成数量:").concat(String.valueOf(Optional.ofNullable(vo.getUndoneTask()).orElse(0)))).collect(Collectors.joining("\r\n")); taskReportVO.setCompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getFinishTask())).collect(Collectors.summingInt(TaskCountVO::getFinishTask))); taskReportVO.setCompleteSituation(finishSituation); taskReportVO.setIncompleteNum(list.stream().filter(taskCountVO -> Func.isNotEmpty(taskCountVO.getUndoneTask())).collect(Collectors.summingInt(TaskCountVO::getUndoneTask))); 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 1f80b1b..1ebf282 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 @@ -1272,7 +1272,7 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor double ticketInfoProportion = sum == 0 ? 0 : new BigDecimal(qualifiedNum).divide(new BigDecimal(sum),2, RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)) .setScale(2,RoundingMode.HALF_DOWN).doubleValue(); - String phenomenonConclusion = "5、本月开票%s张,合格率百分之%s%%"; + String phenomenonConclusion = "5、本月开票%s张,合格率为%s%%"; conclusion.append(String.format(phenomenonConclusion, sum, ticketInfoProportion)).append(";\r\n"); }else { conclusion.append("5、本月未开票;\r\n"); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 69c85ed..743651d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -539,7 +539,12 @@ public class TicketProcessServiceImpl implements TicketProcessService { } WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); if(ObjectUtil.isNotEmpty(workTicketFinish)) { - workTicketFinishService.saveOrUpdate(workTicketFinish); + WorkTicketFinish res = workTicketFinishService.selectByTicketId(workTicketFinish.getTicketId()); + if (ObjectUtils.isEmpty(res)){ + workTicketFinishService.save(workTicketFinish); + }else { + workTicketFinishService.updateByTicketId(workTicketFinish); + } } // 推送消息 new Thread(() -> this.sendMessage(workTicket,response.getUserId())).start(); From 21706936f683826db171b94e6ddf35ca66bba556 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Mon, 13 May 2024 23:21:22 +0800 Subject: [PATCH 072/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E7=BB=9F=E8=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml | 4 ++-- .../access/service/impl/OperAccessTaskServiceImpl.java | 4 ++-- .../operational/defect/controller/OperDefectController.java | 4 ++++ .../service/impl/OperStationMonthReportServiceImpl.java | 13 +++++++++++-- .../hnac/hzims/operational/report/vo/FDPRunReportVO.java | 5 +++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml index 432259f..776535a 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml @@ -394,10 +394,10 @@ where t.id = u.task_id and t.is_deleted = 0 and u.is_deleted = 0 and u.user_id is not null - and t.PLAN_START_TIME >= #{startTime} + and t.CREATE_TIME >= #{startTime} - and t.PLAN_END_TIME <= #{endTime} + and t.CREATE_TIME <= #{endTime} AND t.CREATE_DEPT IN diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java index 3242e57..8504ca8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java @@ -297,8 +297,8 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl deptIdList = (List) params.get("deptId"); List operAccessTaskEntityList = this.list(new LambdaQueryWrapper() {{ - ge(OperAccessTaskEntity::getPlanStartTime, startDate); - le(OperAccessTaskEntity::getPlanStartTime, endDate); + ge(OperAccessTaskEntity::getCreateTime, startDate); + le(OperAccessTaskEntity::getCreateTime, endDate); in(OperAccessTaskEntity::getCreateDept, deptIdList); }}); List res =new ArrayList<>(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java index c5eba9b..b6a472e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java @@ -8,6 +8,7 @@ import com.hnac.hzims.common.invalid.ObjectRequiredInvalid; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.vo.OperDefectVO; @@ -93,6 +94,9 @@ public class OperDefectController extends BladeController { BusinessType.GENCODE, action = "获取缺陷的统计月报") public R> getDefectStatistics(@ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month, @RequestParam String deptId) { + if(StringUtils.isEmpty(deptId)){ + return R.data(new HashMap<>()); + } Map defectStatistics = defectService.getDefectStatistics(month,deptId); return R.data(defectStatistics); } 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 1ebf282..0d62ff1 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 @@ -487,6 +487,9 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor fdpRunReportVO.setIndex(index); fdpRunReportVO.setLastBeginTime(fdpFaultHistoryDataEntity.getCreateTime()); fdpRunReportVO.setType("智能预警"); + fdpRunReportVO.setOrd(fdpFaultHistoryDataEntity.getOrd()); + List stationEntities = stationEntityList.stream().filter(s -> s.getCode().equals(fdpFaultHistoryDataEntity.getStation())).collect(Collectors.toList()); + fdpRunReportVO.setStation(stationEntities.get(0).getName()); fdpRunReportVO.setContent(fdpFaultHistoryDataEntity.getName()); fdpRunReportVO.setNum(String.valueOf(fdpFaultHistoryDataEntities.size())); fdpRunReportVO.setReason(fdpFaultHistoryDataEntity.getDiagReason()); @@ -1222,11 +1225,17 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor List inspectReportVOList = stationReportAllVo.getInspectReportVOList(); int completeInspectTaskNum =inspectReportVOList.stream().filter(vo ->"合计".equals(vo.getUserName())).mapToInt(RunReportVO::getCompleteNum).sum(); int incompleteInspectTaskNum =inspectReportVOList.stream().filter(vo ->"合计".equals(vo.getUserName())).mapToInt(RunReportVO::getIncompleteNum).sum(); + int sum=completeInspectTaskNum+incompleteInspectTaskNum; + Double rate =0.0; + if (sum!=0){ + rate=new BigDecimal(completeInspectTaskNum).divide(new BigDecimal(sum),4,BigDecimal.ROUND_UP) + .multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_UP).doubleValue(); + } if (completeInspectTaskNum == 0 && incompleteInspectTaskNum == 0) { conclusion.append("3、无巡检任务;\r\n"); } else { - String inspectTaskConclusion = "3、%s个巡检任务,已执行%s个巡检任务。"; - conclusion.append(String.format(inspectTaskConclusion, (completeInspectTaskNum + incompleteInspectTaskNum), completeInspectTaskNum)).append(";\r\n"); + String inspectTaskConclusion = "3、%s个巡检任务,已执行%s个巡检任务,完成率%s%%"; + conclusion.append(String.format(inspectTaskConclusion, sum, completeInspectTaskNum,rate)).append(";\r\n"); } } else { conclusion.append("3、无巡检任务;\r\n"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java index 0b40dc2..7f59d7f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java @@ -22,6 +22,11 @@ public class FDPRunReportVO implements Serializable { @ApiModelProperty("告警内容") private String content; + @ApiModelProperty("告警位置") + private String ord; + + @ApiModelProperty("站点") + private String station; @ApiModelProperty("告警类型") private String type; From 143758e4054debcf478bb88f7784d880bbfbbc17 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 14 May 2024 15:36:21 +0800 Subject: [PATCH 073/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E7=BB=9F=E8=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/service/impl/OperStationMonthReportServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 0d62ff1..7e7de11 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 @@ -487,9 +487,11 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor fdpRunReportVO.setIndex(index); fdpRunReportVO.setLastBeginTime(fdpFaultHistoryDataEntity.getCreateTime()); fdpRunReportVO.setType("智能预警"); - fdpRunReportVO.setOrd(fdpFaultHistoryDataEntity.getOrd()); + fdpRunReportVO.setOrd(fdpFaultHistoryDataEntity.getOrd()==null?"":fdpFaultHistoryDataEntity.getOrd()); List stationEntities = stationEntityList.stream().filter(s -> s.getCode().equals(fdpFaultHistoryDataEntity.getStation())).collect(Collectors.toList()); - fdpRunReportVO.setStation(stationEntities.get(0).getName()); + if (CollectionUtil.isNotEmpty(stationEntities)){ + fdpRunReportVO.setStation(stationEntities.get(0).getName()); + } fdpRunReportVO.setContent(fdpFaultHistoryDataEntity.getName()); fdpRunReportVO.setNum(String.valueOf(fdpFaultHistoryDataEntities.size())); fdpRunReportVO.setReason(fdpFaultHistoryDataEntity.getDiagReason()); From 8281f30cddb6864f712194bfcd1cec203f7bce1c Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 15 May 2024 11:13:12 +0800 Subject: [PATCH 074/151] =?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=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MainSystemMonitoringServiceImpl.java | 1 + .../service/impl/OperStationMonthReportServiceImpl.java | 15 ++++++++++----- .../java/com/hnac/hzims/operational/util/ObjectUtils.java | 2 +- 3 files changed, 12 insertions(+), 6 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 ea01dee..171d8bc 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 @@ -1360,6 +1360,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer String currentMon = TimeUtils.getMon(year, mon); Integer count=0; Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + log.info("Redis近三年发电量数据查询:"+powerMapThree); for (Map.Entry> deviceMap : powerMapThree.entrySet()) { for (StationEntity stationEntity : stationEntityList) { if (stationEntity.getId().equals(deviceMap.getKey())) { 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 7e7de11..4ea709d 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 @@ -344,16 +344,19 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor Integer currentYear = calendar.get(Calendar.YEAR); if (year>currentYear-3) { mainSystemMonitoringService.getElectricSituationByRedis(yearAndMonth, reportVOS, stationEntityList); + log.info("电站发电情况"+reportVOS.toString()); }else { stationEntityList.forEach(stationEntity -> { List stationReportVOList = mainSystemMonitoringService.getElectricSituationV2(yearAndMonth, stationEntity.getCode()); reportVOS.addAll(stationReportVOList); }); + log.info("电站发电情况"+reportVOS.toString()); } getSumStationRunReport(reportVOS); stationReportAllVo.setStationReportVOList(reportVOS); + log.info("电站发电量总览"+reportVOS.toString()); }catch (Exception e){ - log.error("", e); + log.error("getStationMonthReportV2电站发电量报错", e); System.out.println(e); }finally { countDownLatch.countDown(); @@ -523,11 +526,12 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor stationRunReportVO.setStationName("合计"); if (CollectionUtil.isNotEmpty(reportVOS)){ double sumPowerMonPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerMonPlan).sum(); - stationRunReportVO.setPowerMonPlan(sumPowerMonPlan); + stationRunReportVO.setPowerMonPlan(new BigDecimal(sumPowerMonPlan).setScale(2,BigDecimal.ROUND_UP).doubleValue()); double sumFinishPowerMon = reportVOS.stream().map(StationRunReportVO::getFinishPowerMon).mapToDouble(s -> Double.valueOf(s)).sum(); - stationRunReportVO.setFinishPowerMon(String.valueOf(sumFinishPowerMon)); + stationRunReportVO.setFinishPowerMon(new BigDecimal(sumFinishPowerMon).setScale(2,BigDecimal.ROUND_UP).toString()); if (!ObjectUtils.isEmpty(sumPowerMonPlan)) { - BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan)).setScale(2, BigDecimal.ROUND_UP); + BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan),4,BigDecimal.ROUND_UP) + .multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP); stationRunReportVO.setPowerMonRate(String.valueOf(powerMonRate)); }else { stationRunReportVO.setPowerMonRate("0.0"); @@ -537,7 +541,8 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor 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); + BigDecimal powerYearRate = new BigDecimal(sumFinishPowerYear).divide(new BigDecimal(sumPowerYearPlan),4,BigDecimal.ROUND_UP) + .multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP); stationRunReportVO.setPowerYearRate(String.valueOf(powerYearRate)); }else { stationRunReportVO.setPowerYearRate("0.0"); 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 341e2d5..cd140eb 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 @@ -85,7 +85,7 @@ public class ObjectUtils { public static BigDecimal objDivide(String s){ BigDecimal bigDecimal = new BigDecimal(s); - BigDecimal res = bigDecimal.divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_UP); + BigDecimal res = bigDecimal.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2, BigDecimal.ROUND_UP); return res; } } From 65da3b9d29a9cd7f74369eb29210251fb28361e6 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 17 May 2024 09:37:18 +0800 Subject: [PATCH 075/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=88=A4=E6=96=ADbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java index a166dff..b1af6c9 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java @@ -637,8 +637,8 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl libraryExcel.getLowerLimit()) { + if (ObjectUtil.isNotEmpty(libraryExcel.getLowerLimit()) && ObjectUtil.isNotEmpty(libraryExcel.getUpperLimit())) { + if (libraryExcel.getLowerLimit() > libraryExcel.getUpperLimit()) { errors.add("库存下限不能大于库存上限"); } } From c0d84e628e121c53a27bbd3206775ee4854bba37 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 17 May 2024 10:11:08 +0800 Subject: [PATCH 076/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=BB=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java index 31509db..480fb07 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java @@ -60,7 +60,7 @@ public class ArtemisPostUtils { /* 返回url地址 */ - if(null != result || !"".equals(result)){ + if((null != result) && !"".equals(result)){ JSONObject json = JSONObject.parseObject(result); json = JSONObject.parseObject(json.getString("data")); From d27cd34e90c453a8a6d719e99017f3b2e991b0e6 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Mon, 20 May 2024 15:09:01 +0800 Subject: [PATCH 077/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3:=E4=BA=A4=E6=8E=A5?= =?UTF-8?q?=E7=8F=AD=E5=80=BC=E7=8F=AD=E6=97=A5=E5=BF=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/duty/service/impl/ImsDutyRecServiceImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 3f45160..bad0c0d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -245,7 +245,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl { + log.error("交接班请求报错"+flowResult.getMsg()); throw new ServiceException(flowResult.getMsg()); }); return flowResult.getData(); @@ -487,6 +488,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyLogEntity::getDutyId, dutyId); + last(" limit 1;"); }}); imsDutyRecVO.setImsDutyLogEntity(dutyLogEntity); } @@ -1606,10 +1608,6 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl Date: Tue, 21 May 2024 09:10:51 +0800 Subject: [PATCH 078/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3:=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/source/service/impl/MessageServiceImpl.java | 14 ++++++++++---- .../hzims/message/service/impl/WxMessageServiceImpl.java | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 105bf73..ffa434b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -146,9 +146,8 @@ public class MessageServiceImpl implements MessageService { log.error("微信消息发送失败:站点code获取失败 : {}",entity); return; } - Long dept = station.getData().getCreateDept(); // 获取站点用户 - R> result = userClient.userList("200000",dept); + R> result = userClient.userByDeptIdLevel(station.getData().getRefDept(),0); if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { log.error("微信消息发送失败:用户获取失败 : {}",entity); return; @@ -168,9 +167,9 @@ public class MessageServiceImpl implements MessageService { message.setTaskId(entity.getId()); // 微信参数键值对 HashMap map = new HashMap<>(); - map.put("thing18",entity.getStationName()); + map.put("thing18",getTruncateString(entity.getStationName(), 29)); // map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备")); - map.put("thing11",entity.getAlarmContext()); + map.put("thing11",getTruncateString(entity.getAlarmContext(), 29)); map.put("time2",entity.getAlarmTime()); map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); message.setMap(map); @@ -186,4 +185,11 @@ public class MessageServiceImpl implements MessageService { message.setTenantId(station.getData().getTenantId()); messageClient.sendWxMessage(message); } + private String getTruncateString(String ruleDefName, int maxSize) { + if (ruleDefName.length()<= maxSize){ + return ruleDefName; + }else { + return ruleDefName.substring(0, maxSize - 3) + "..."; + } + } } \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java index cb04c86..dd4e03e 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java @@ -92,7 +92,10 @@ public class WxMessageServiceImpl implements IMessageService { template.setUserIds(Arrays.stream(message.getUserIds().split(",")).collect(Collectors.toList())); template.setTenantId("200000"); R result = wxPushClient.sendPushTemplateByUserId(template); - return result.isSuccess(); + if(result.isSuccess()&&ObjectUtil.isNotEmpty(result.getData())){ + return true; + } + return false; } private String getTruncateString(String ruleDefName, int maxSize) { From 45141de4f7770a60db98b3275b95d938c2d406cb Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 22 May 2024 19:02:08 +0800 Subject: [PATCH 079/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E6=9F=A5=E8=AF=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/config/constants/AlarmConstants.java | 1 + .../hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java | 2 +- .../com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java | 3 +- .../hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java | 2 +- .../java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 10 ++-- .../com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java | 3 +- .../hnac/hzims/alarm/mqtt/VideoMqttConsumer.java | 2 +- .../source/service/impl/LevelAlarmServiceImpl.java | 2 +- .../source/service/impl/MessageServiceImpl.java | 68 +++++++++++++++++----- .../service/impl/SystemAlarmServiceImpl.java | 6 +- .../hzims-alarm/src/main/resources/db/2.0.0.sql | 2 + 11 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java index 0128e39..ab035cd 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java @@ -7,6 +7,7 @@ import java.util.List; * @author ysj */ public interface AlarmConstants { + public static final String PATTERN_DATETIME_MILLIS = "yyyy-MM-dd HH:mm:ss.SSS"; String APP_NAME = "hzims-alarm"; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java index f14d600..25bea94 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java @@ -26,7 +26,7 @@ public class DroolsMqttConsumer implements SubscribeCallBack { private AlarmSaveService alarmSaveService; @Override public void onMessage(Map data) { - System.out.println("监听到消息"+data.toString()); + log.info("DroolsMqttConsumer监听到消息"+data.toString()); String s = JSONObject.toJSONString(data); //消费代码 List alarmEntities = droolsAlarmService.receiveMessage(s); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java index c4c2d97..827825c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java @@ -29,9 +29,8 @@ public class FdpMqttConsumer implements SubscribeCallBack { @Override public void onMessage(Map data) { String s = JSONObject.toJSONString(data); - log.error("监听Fdp消息 : {}" ,s); + log.info("监听Fdp消息 : {}" ,s); //消费代码 - List alarmEntities = fdpAlarmService.receiveMessage(s); if(CollectionUtil.isEmpty(alarmEntities)){ return; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java index 82880ad..97c53b0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java @@ -29,7 +29,7 @@ public class HZ300MqttConsumer implements SubscribeCallBack { private AlarmSaveService alarmSaveService; @Override public void onMessage(Map data) { - log.error("HZ3000队列监听到消息 : {}",data); + log.info("HZ3000队列监听到消息 : {}",data); //消费代码 List alarmEntities = systemAlarmService.receiveMessage(JSONObject.toJSONString(data)); if(CollectionUtil.isEmpty(alarmEntities)){ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 09651fd..6a2c34e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -58,23 +58,23 @@ public class MqttConfig { //fdp AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer); - log.info(fdpClient.toString()); + log.info(fdpClient.toString()+fdpClient.getClientId()); //drools DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); - log.info(droolsClient.toString()); + log.info(droolsClient.toString()+droolsClient.getClientId()); //Soe SoeSubscribe soeSubscribe = new SoeSubscribe(); MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); - log.info(soeClient.toString()); + log.info(soeClient.toString()+soeClient.getClientId()); //hz3000 HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); - log.info(hz3000Client.toString()); + log.info(hz3000Client.toString()+hz3000Client.getClientId()); //视频 SoeSubscribe subscribe = new SoeSubscribe(); MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); - log.info(videoClient.toString()); + log.info(videoClient.toString()+videoClient.getClientId()); }catch (MqttException e){ log.error(e.toString()) ; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java index 5a29fff..13fae87 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/SoeMqttConsumer.java @@ -27,7 +27,7 @@ public class SoeMqttConsumer implements SubscribeCallBack { private AlarmSaveService alarmSaveService; @Override public void onMessage(Map data) { - System.out.println("监听到消息"+data.toString()); + log.info("SoeMqttConsumer监听到消息"+data.toString()); String s = JSONObject.toJSONString(data); //消费代码 List alarmEntities = soeAlarmService.receiveMessage(s); @@ -36,7 +36,6 @@ public class SoeMqttConsumer implements SubscribeCallBack { alarmSaveService.save(alarmEntities); }catch (Exception e){ log.error("条件告警数据处理报错(SoeAlarm):"+e); - System.out.println("规则引擎告警数据处理报错(SoeAlarm):"+e); } } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java index 053c4df..447db7b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java @@ -26,7 +26,7 @@ public class VideoMqttConsumer implements SubscribeCallBack { private AlarmSaveService alarmSaveService; @Override public void onMessage(Map data) { - System.out.println("监听到消息"+data.toString()); + log.info("VideoMqttConsumer队列监听到消息 : {}",data); String s = JSONObject.toJSONString(data); //消费代码 List alarmEntities = videoAlarmService.receiveMessage(s); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java index 41b318f..fe035f1 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java @@ -91,7 +91,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { AlarmEntity entity = new AlarmEntity(); entity.setAlarmSource(AlarmConstants.LEVEL_ALARM); entity.setAlarmId(level.getId()); - entity.setAlarmTime(DateUtil.parse(level.getTs(), "yyyy-MM-dd HH:mm:ss.s")); + entity.setAlarmTime(new Date(level.getTs())); entity.setAlarmType(level.getType()); entity.setRealId(level.getSignage()); entity.setAlarmContext(level.getName()); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index ffa434b..378a88d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.jackson.JsonUtil; @@ -27,6 +28,7 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.UserInfo; import org.springblade.system.user.feign.IUserClient; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.*; @@ -40,9 +42,10 @@ import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MAN */ @Slf4j @Service -@AllArgsConstructor +@RequiredArgsConstructor public class MessageServiceImpl implements MessageService { + private final ISysClient sysClient; private final IUserClient userClient; @@ -51,6 +54,14 @@ public class MessageServiceImpl implements MessageService { private final IStationClient stationClient; + @Value("${hzims.msg.template}") + private String msgTemplate; + @Value("${hzims.msg.enabled}") + private Boolean msgEnabled; + @Value("${hzims.wxPush.template}") + private String wxPushTemplate; + @Value("${hzims.wxPush.enabled}") + private Boolean wxPushEnabled; /** * web/app消息推送 * @param entity : 告警对象 @@ -106,14 +117,23 @@ public class MessageServiceImpl implements MessageService { // } //写死传给固定用户 // List phoneList=Arrays.asList("18351807087","18163793336","13725599914"); - List phoneList=Arrays.asList("18351807087","18163793336","18285121497"); - for (String phone : phoneList) { - R userByPhone = userClient.getUserByPhone("200000", phone); - if (userByPhone.isSuccess()&&ObjectUtils.isNotEmpty(userByPhone.getData())){ - users.add(userByPhone.getData().getUser()); + if (msgEnabled){ + users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); + if(CollectionUtil.isEmpty(users)){ + log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity); + return; + } + log.info("短信发送用户列表",users); + }else { + List phoneList = Arrays.asList("18351807087", "18163793336", "18285121497"); + for (String phone : phoneList) { + R userByPhone = userClient.getUserByPhone("200000", phone); + if (userByPhone.isSuccess() && ObjectUtils.isNotEmpty(userByPhone.getData())) { + users.add(userByPhone.getData().getUser()); + } } + log.info("短信发送用户列表",users); } - SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() .deptId(entity.getCreateDept()) .taskId(entity.getId()) @@ -122,7 +142,7 @@ public class MessageServiceImpl implements MessageService { .content(entity.getAlarmContext()) .subject("告警短信通知") .tenantId(entity.getTenantId()) - .resourceCode(AlarmConstants.SMS_MESSAGE_TEMPLATE_CODE) + .resourceCode(msgTemplate) .pusher(users.stream().map(o->o.getId().toString()).collect(Collectors.joining(","))) .createUser(CommonConstant.SYSTEM_USER) .params(new HashMap(){{ @@ -146,19 +166,35 @@ public class MessageServiceImpl implements MessageService { log.error("微信消息发送失败:站点code获取失败 : {}",entity); return; } + List userList=new ArrayList<>(); // 获取站点用户 - R> result = userClient.userByDeptIdLevel(station.getData().getRefDept(),0); - if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - log.error("微信消息发送失败:用户获取失败 : {}",entity); - return; + if (wxPushEnabled){ + R> result = userClient.userByDeptIdLevel(station.getData().getRefDept(),1); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + log.error("微信公众号消息发送失败:用户获取失败 : {}",entity); + return; + } + userList.addAll(result.getData()); + log.info("短信发送用户列表",userList); + }else { + //内测只推给对应的3个用户 + List phoneList = Arrays.asList("18351807087", "18163793336", "18285121497"); + for (String phone : phoneList) { + R userByPhone = userClient.getUserByPhone("200000", phone); + if (userByPhone.isSuccess() && ObjectUtils.isNotEmpty(userByPhone.getData())) { + userList.add(userByPhone.getData().getUser()); + } + } + log.info("短信发送用户列表",userList); } + String userIds = userList.stream().map(o -> String.valueOf(o.getId())).distinct().collect(Collectors.joining(",")); WxMessageDTO message = new WxMessageDTO(); // 模板Id - message.setTemplateId("hIgINCsjpG-gyCKh8wzwBeRL9tanTLqRDgv-X8B9vyc"); + message.setTemplateId(wxPushTemplate); // // 微信消息跳转地址 // message.setSkipUrl("http://baidu.com"); // 机构Id - message.setDeptId(result.getData().get(0).getId()); + message.setDeptId(station.getData().getRefDept()); // 业务关键字 message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); // 业务分类关键字 @@ -178,9 +214,9 @@ public class MessageServiceImpl implements MessageService { // 消息主题 message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); // 推送用户 - message.setUserIds(result.getData().stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(","))); + message.setUserIds(userIds); // 创建用户 - message.setCreateUser(result.getData().get(0).getId()); + message.setCreateUser(userList.get(0).getId()); // 租户Id message.setTenantId(station.getData().getTenantId()); messageClient.sendWxMessage(message); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java index 8f3bee4..b829956 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java @@ -83,9 +83,9 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { private AlarmEntity getAlarmEntity(SystemAlarmVo item) { AlarmEntity entity = new AlarmEntity(); entity.setAlarmId(item.getId()); - Date date = new Date(); - date.setTime(item.getTs()); - entity.setAlarmTime(DateUtil.parse(DateUtil.format(date,DateUtil.PATTERN_DATETIME),DateUtil.PATTERN_DATETIME)); +// Date date = new Date(item.getTs()); +// entity.setAlarmTime(DateUtil.parse(item.getTs().toString(),PATTERN_DATETIME_MILLIS)); + entity.setAlarmTime( new Date(item.getTs())); entity.setAlarmContext(item.getContext()); entity.setAlarmType(item.getType()); entity.setAlarmStatus(item.getState()); diff --git a/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql b/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql new file mode 100644 index 0000000..0c98175 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/resources/db/2.0.0.sql @@ -0,0 +1,2 @@ +ALTER TABLE `hzims_alarm` + MODIFY COLUMN `ALARM_TIME` datetime(3) NULL DEFAULT NULL COMMENT '告警时间' AFTER `ALARM_COUNT`; \ No newline at end of file From 434001be887cef6e1d3ea7b70f6dc37fa2b615eb Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 22 May 2024 19:05:10 +0800 Subject: [PATCH 080/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java index 16a7a37..e22e676 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java @@ -28,6 +28,8 @@ import java.util.Date; import java.util.List; import java.util.stream.Collectors; +import static com.hnac.hzims.alarm.config.constants.AlarmConstants.PATTERN_DATETIME_MILLIS; + /** * 华自3000告警实现类 * @@ -103,7 +105,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { private AlarmEntity getAlarmEntity(DeviceSoeVO item) { AlarmEntity entity = new AlarmEntity(); entity.setAlarmId(item.getId()); - entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); + entity.setAlarmTime(DateUtil.parse(item.getTs(), PATTERN_DATETIME_MILLIS)); entity.setAlarmContext(item.getSoeExplain()); entity.setAlarmType(AlarmHandleConstant.VIDEO_ALARM); entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus())); From 75e08d0d0faf7751160d8b0f25a43e6158d20842 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 22 May 2024 19:22:40 +0800 Subject: [PATCH 081/151] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E9=99=90=E5=88=B6=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E4=B8=BA20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 378a88d..304f56b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -203,9 +203,9 @@ public class MessageServiceImpl implements MessageService { message.setTaskId(entity.getId()); // 微信参数键值对 HashMap map = new HashMap<>(); - map.put("thing18",getTruncateString(entity.getStationName(), 29)); + map.put("thing18",getTruncateString(entity.getStationName(), 17)); // map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备")); - map.put("thing11",getTruncateString(entity.getAlarmContext(), 29)); + map.put("thing11",getTruncateString(entity.getAlarmContext(), 17)); map.put("time2",entity.getAlarmTime()); map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); message.setMap(map); From 5916d6ac9de69250510b28afbee5ae672107969c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 23 May 2024 11:09:30 +0800 Subject: [PATCH 082/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=99=90=E5=88=B61=E5=A4=A9=E4=B8=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/service/impl/AlarmSaveServiceImpl.java | 16 +++++++++------- .../hzims/alarm/show/mapper/AlarmHandleMapper.java | 4 ++++ .../hzims/alarm/show/mapper/AlarmHandleMapper.xml | 20 ++++++++++++++++++++ .../show/service/impl/AlarmHandleServiceImpl.java | 16 +++++++++------- .../interactive/service/IInteractiveService.java | 2 +- .../service/impl/InteractiveServiceImpl.java | 2 +- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index 3bdfb4a..7cc733b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -72,19 +72,21 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { return; } // 告警已处理 - if(handlers.contains(alarm.getAlarmContext())){ + if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){ return; } // 告警已延后处理 - if(delays.contains(alarm.getAlarmContext())){ + if(CollectionUtil.isNotEmpty(delays) && delays.contains(alarm.getAlarmContext())){ return; } // 近5分钟内告警重复 - for (String key : keys) { - String value = stringRedisTemplate.opsForValue().get(key); - if (value.equals(optional.get().getName()+alarm.getAlarmContext())){ - return; - } + if(CollectionUtil.isNotEmpty(keys)){ + for (String key : keys) { + String value = stringRedisTemplate.opsForValue().get(key); + if (value.equals(optional.get().getName()+alarm.getAlarmContext())){ + return; + } + } } // fpd告警拼接站点名称 if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.java index 2f4527c..c80c634 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.java @@ -21,4 +21,8 @@ public interface AlarmHandleMapper extends UserDataScopeBaseMapper selectHandlePage(IPage page, @Param("param") HandleQueryVo param); List handles(@Param("start") String start,@Param("end") String end); + + List sameDayContent(@Param("start") String start,@Param("end") String end); + + List incompleteContent(@Param("end") String end); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml index 971f958..0a0ff34 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml @@ -40,4 +40,24 @@ AND (HANDLER.DELAY_TIME > #{end} OR HANDLER.DELAY_TIME IS NULL) + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index b53128a..0a954e2 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -31,10 +31,7 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -172,12 +169,16 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl sameDayContent() { - return null; + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY,-1); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + return this.baseMapper.sameDayContent(start,end); } /** @@ -186,6 +187,7 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl incompleteContent() { - return null; + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + return this.baseMapper.incompleteContent(end); } } 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 34c0a4f..2f6588a 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 @@ -42,5 +42,5 @@ public interface IInteractiveService { */ R knowledgeAsk(String question, String sessionId, String userId, String knowledge); - Object sendRemoteControl(ControlDTO operate); + R sendRemoteControl(ControlDTO operate); } 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 0395fd4..f5571dd 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 @@ -274,7 +274,7 @@ public class InteractiveServiceImpl implements IInteractiveService { * @return */ @Override - public Object sendRemoteControl(ControlDTO operate) { + public R sendRemoteControl(ControlDTO operate) { return remoteClient.sendCtrl(operate); } } From dc8e301495d8da39f72cf41e3e05857ed9ba60e7 Mon Sep 17 00:00:00 2001 From: liwen Date: Thu, 23 May 2024 14:58:39 +0800 Subject: [PATCH 083/151] =?UTF-8?q?update:=20=E8=80=83=E8=AF=95=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=8F=8A=E6=A0=BC=E5=88=86=E8=AE=BE=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/entity/TestEntity.java | 10 +++++----- .../hzims/safeproduct/service/impl/TestScoreServiceImpl.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java index 0235e18..27ae3d7 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java @@ -60,11 +60,11 @@ public class TestEntity extends BaseEntity { @ApiModelProperty("考试结束时间") private Date testEndTime; -// @NotNull -// @Min(value = 0, message = "及格分必须大于等于0") -// @Max(value = 100, message = "及格分必须小于等于100") -// @ApiModelProperty("及格分") -// private Integer passingScore; + @NotNull + @Min(value = 0, message = "及格分必须大于等于0") + @Max(value = 100, message = "及格分必须小于等于100") + @ApiModelProperty("及格分") + private Integer passingScore; @NotNull @Size(max = 255, message = "考试地点字段长度不能超过255") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java index a075bb2..597e48e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java @@ -126,7 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl s.getScore() != null).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { testScoreSumVO.setActualPeopleNum(list.size()); - List passCollect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList()); + List passCollect = list.stream().filter(s -> s.getScore() > testScoreSumVO.getPassingScore()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) { double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue(); testScoreSumVO.setPercentage(result); From 3e3fac67aec56f48d3ad591cbefa3057fad9e858 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 24 May 2024 11:59:43 +0800 Subject: [PATCH 084/151] =?UTF-8?q?fix:=E5=AE=9E=E6=97=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InteractiveController.java | 4 ++-- .../service/impl/ExtraResolveStrategyService.java | 17 +++++++++++++---- .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 3 +-- .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java 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 a80b2aa..40e79b3 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 @@ -74,7 +74,7 @@ public class InteractiveController { @ApiOperation("下发遥控指令") @ApiOperationSupport(order = 6) @PostMapping("/sendRemoteControl") - public R sendRemoteControl(@RequestBody ControlDTO operate) { - return R.data(interactiveService.sendRemoteControl(operate)); + public R sendRemoteControl(@RequestBody ControlDTO operate) { + return interactiveService.sendRemoteControl(operate); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index bcda8cb..9502fec 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -18,16 +18,15 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.dto.ControlDTO; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.time.format.DateTimeFormatter; +import java.util.*; import java.util.stream.Collectors; /** @@ -38,6 +37,10 @@ import java.util.stream.Collectors; @AllArgsConstructor public class ExtraResolveStrategyService { + public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; + + public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN_DATETIME); + private final IStationClient stationClient; private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; @@ -85,6 +88,11 @@ public class ExtraResolveStrategyService { result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); Map param = new HashMap(1); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); + if(Func.isNotEmpty(data) && Func.isNotEmpty(data.getReal()) && Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { + RealDataVO real = data.getReal(); + Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); + real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + } param.put("data", data); result.setParams(param); return result; @@ -101,6 +109,7 @@ public class ExtraResolveStrategyService { param.put("control",funcVOR.getData()); param.put("deviceName",remoteParam.getDeviceName()); param.put("projectName",remoteParam.getProjectName()); + param.put("deviceCode",remoteParam.getDeviceId()); param.put("value",remoteParam.getValue()); result.setParams(param); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java index d3ea096..1f2fcfd 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField; import lombok.Data; import java.io.Serializable; -import java.util.Map; /** * @Author: huangxing @@ -26,7 +25,7 @@ public class DataVO implements Serializable { private String method; /**实时数据结果集**/ - private Map real; + private RealDataVO real; private DataItemVO item; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java new file mode 100644 index 0000000..16a5a46 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 10:26 + */ +@Data +public class RealDataVO implements Serializable { + + private String time; + + private String value; + +} From 8252fcf39a2937171ade496d88db66597ce29a8e Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 24 May 2024 12:01:28 +0800 Subject: [PATCH 085/151] =?UTF-8?q?add:=E5=AE=89=E5=85=A8=E5=B7=A5?= =?UTF-8?q?=E5=99=A8=E5=85=B7=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/template/SafeToolTemplate.html | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html diff --git a/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html b/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html new file mode 100644 index 0000000..8e377ea --- /dev/null +++ b/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + +
工器具名称${data_1}
创建日期${data_2}
+ +
+ + From 323b16b5802797b1870c3fe052b0736265a23170 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 24 May 2024 15:47:17 +0800 Subject: [PATCH 086/151] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/entity/StationRelation.java | 130 ++++++++++++++++++++ .../operational/station/vo/HomeMapStationVo.java | 44 +++++++ .../operational/station/RunReportConstant.java | 5 + .../station/controller/StationController.java | 7 +- .../controller/StationRelationController.java | 134 +++++++++++++++++++++ .../station/mapper/StationRelationMapper.java | 8 ++ .../station/mapper/StationRelationMapper.xml | 5 + .../station/service/IStationRelationService.java | 19 +++ .../station/service/IStationService.java | 3 + .../service/impl/StationRelationServiceImpl.java | 47 ++++++++ .../station/service/impl/StationServiceImpl.java | 28 +++++ .../operational/src/main/resources/db/2.0.5.sql | 19 +++ 12 files changed, 446 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java create mode 100644 hzims-service/operational/src/main/resources/db/2.0.5.sql diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java new file mode 100644 index 0000000..509ca22 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java @@ -0,0 +1,130 @@ +package com.hnac.hzims.operational.station.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import okhttp3.internal.annotations.EverythingIsNonNull; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 站点和霍山生态流量电站的关联关系表 + * @author tanghaihao + * @date 2023年10月08日 13:58 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("station_relation") +public class StationRelation implements Serializable { + private static final long serialVersionUID=1L; + + /** + * ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 站点编码 + */ + @TableField("station_code") + private String stationCode; + + /** + * 站点名称 + */ + @TableField(exist = false) + private String stationName; + + /** + * 设备编码 + */ + @TableField("device_code") + private String deviceCode; + + /** + * 设备名称 + */ + @TableField(exist = false) + private String deviceName; + + /** + * 核定流量 + */ + @TableField("flow_value") + private String flowValue; + + /** + * 低级告警负责人id + */ + @TableField("low_soe_user_id") + private String lowSoeUserId; + + /** + * 低级告警电话号码 + */ + @TableField("low_soe_phone") + private String lowSoePhone; + + /** + * 中级告警负责人id + */ + @TableField("middle_soe_user_id") + private String middleSoeUserId; + + /** + * 中级告警电话号码 + */ + @TableField("middle_soe_phone") + private String middleSoePhone; + + /** + * 高级告警负责人id + */ + @TableField("high_soe_user_id") + private String highSoeUserId; + + /** + * 高级告警电话号码 + */ + @TableField("high_soe_phone") + private String highSoePhone; + + /** + * 当日是否发送预警 + */ + @TableField("send_warning") + private Integer sendWarning; + + /** + * 当日是否发送告警 + */ + @TableField("send_soe") + private Integer sendSoe; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 逻辑删除 + */ + @TableField("is_deleted") + private Integer isDeleted; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java new file mode 100644 index 0000000..3aa7c25 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java @@ -0,0 +1,44 @@ +package com.hnac.hzims.operational.station.vo; + +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; + +/** + * @author ysj + */ +@Data +public class HomeMapStationVo { + + @ApiModelProperty("行政区划") + private String areaCode; + + @ApiModelProperty("编号") + private String code; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("经度(东经)") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Float lgtd; + + @ApiModelProperty("纬度(北纬)") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Float lttd; + + @ApiModelProperty("所属机构") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long refDept; + + @ApiModelProperty("站点是否为国外 1:是;0:否") + private Boolean isAbroad; + + @ApiModelProperty("所属国家") + private String refCountry; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java index 90d534b..2fae440 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java @@ -5,4 +5,9 @@ public interface RunReportConstant { * 运行月报定时任务 */ String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler"; + + /** + * 数据平台霍山生态流量监测模型标识 + */ + String HS_MODEL_SIGNAGE = "hs_ecological_flow_model"; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 7351f30..ce3a5c3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java @@ -10,6 +10,7 @@ import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.station.vo.HomeMapStationVo; import com.hnac.hzims.operational.station.vo.StationVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -177,9 +178,9 @@ public class StationController extends BladeController { @ApiLog @GetMapping("/getHomeStationList") @ApiOperationSupport(order = 91) - @ApiOperation(value = "获取首页站点列表", notes = "") - public R> getHomeStationList(@RequestParam(value = "deptId", required = false) Long deptId, @RequestParam(value = "types", required = false) List types, @RequestParam(value = "serveType", required = false) Integer serveType) { - return R.data(stationService.getHomeStationList(deptId, types, serveType,true)); + @ApiOperation(value = "获取首页地图站点列表", notes = "") + public R> getHomeStationList() { + return R.data(stationService.homeMapStationVo()); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java new file mode 100644 index 0000000..0241dbd --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java @@ -0,0 +1,134 @@ +package com.hnac.hzims.operational.station.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.station.RunReportConstant; +import com.hnac.hzims.operational.station.entity.StationRelation; +import com.hnac.hzims.operational.station.service.IStationRelationService; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 15:04 + */ + +@RestController +@RequestMapping("/station/station-relation") +@AllArgsConstructor +@Api(value = "站点和霍山生态流量电站的关联关系管理",tags = "站点和霍山生态流量电站的关联关系管理") +public class StationRelationController { + private final IStationRelationService stationRelationService; + private final DeviceClient deviceClient; + + @GetMapping("/list") + @ApiOperation("查询列表") + @ApiOperationSupport(order = 1) + public R> list(StationRelation stationRelation) { + + return R.data(stationRelationService.getStationRelationList(stationRelation)); + } + + @GetMapping("/page") + @ApiOperation("分页查询列表") + @ApiOperationSupport(order = 2) + public R> page(StationRelation stationRelation, Query query) { + + return R.data(stationRelationService.getStationRelationPageList(stationRelation, query)); + } + + @PostMapping("/save") + @ApiOperation("保存") + @ApiOperationSupport(order = 3) + public R save(@RequestBody @Valid StationRelation stationRelation) { + if (Func.isEmpty(stationRelation.getStationCode())) { + return R.fail("站点编码不能为空"); + } + if (Func.isEmpty(stationRelation.getDeviceCode())) { + return R.fail("设备编码不能为空"); + } + if (Func.isEmpty(stationRelation.getLowSoeUserId())) { + return R.fail("低级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getLowSoePhone())) { + return R.fail("低级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getMiddleSoeUserId())) { + return R.fail("中级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getMiddleSoePhone())) { + return R.fail("中级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getHighSoeUserId())) { + return R.fail("高级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getHighSoePhone())) { + return R.fail("高级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getFlowValue())) { + return R.fail("核定流量不能为空"); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode()) + .or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode())); + wrapper.eq(StationRelation::getIsDeleted, 0); + int count = stationRelationService.count(wrapper); + if (count > 0) { + return R.fail("站点关联关系已存在"); + } + return R.status(stationRelationService.save(stationRelation)); + } + + @PostMapping("/update") + @ApiOperation("编辑") + @ApiOperationSupport(order = 4) + public R update(@RequestBody @Valid StationRelation stationRelation) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode()) + .or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode())); + wrapper.eq(StationRelation::getIsDeleted, 0); + wrapper.ne(StationRelation::getId, stationRelation.getId()); + int count = stationRelationService.count(wrapper); + if (count > 0) { + return R.fail("站点关联关系已存在"); + } + return R.status(stationRelationService.updateById(stationRelation)); + } + + @GetMapping("/remove") + @ApiOperation("删除") + @ApiOperationSupport(order = 5) + public R remove(Long id) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.set(StationRelation::getIsDeleted, 1); + wrapper.eq(StationRelation::getId, id); + stationRelationService.update(wrapper); + return R.success("操作成功"); + } + + @GetMapping("/getDevice") + @ApiOperation("获取生态流量模型的设备信息") + @ApiOperationSupport(order = 6) + public R> getDevice() { + R> rData = deviceClient.getDeviceByModelSignage(RunReportConstant.HS_MODEL_SIGNAGE); + if (rData.getCode() == 200) { + List data = rData.getData(); + return R.data(data); + } else { + return R.fail("获取设备信息失败"); + } + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java new file mode 100644 index 0000000..e08e69e --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.operational.station.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.operational.station.entity.StationRelation; + +public interface StationRelationMapper extends BaseMapper { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml new file mode 100644 index 0000000..e1cfa29 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java new file mode 100644 index 0000000..e8e9964 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.station.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.operational.station.entity.StationRelation; +import org.springblade.core.mp.support.Query; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 15:04 + */ +public interface IStationRelationService extends IService { + + List getStationRelationList(StationRelation stationRelation); + + IPage getStationRelationPageList(StationRelation stationRelation, Query query); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 4e3faac..b54f579 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.station.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.vo.HomeMapStationVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationVO; import org.springblade.core.mp.base.BaseService; @@ -136,4 +137,6 @@ public interface IStationService extends BaseService { * @return 更新是否成功 */ boolean updateBatchSort(List req); + + List homeMapStationVo(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java new file mode 100644 index 0000000..6e02935 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.operational.station.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.operational.station.entity.StationRelation; +import com.hnac.hzims.operational.station.mapper.StationRelationMapper; +import com.hnac.hzims.operational.station.service.IStationRelationService; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 14:37 + */ +@Service +public class StationRelationServiceImpl extends ServiceImpl implements IStationRelationService { + @Override + public List getStationRelationList(StationRelation stationRelation) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (Func.isNotEmpty(stationRelation.getStationCode())) { + wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode()); + } + if (Func.isNotEmpty(stationRelation.getDeviceCode())) { + wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()); + } + wrapper.eq(StationRelation::getIsDeleted, 0); + return this.list(wrapper); + } + + @Override + public IPage getStationRelationPageList(StationRelation stationRelation, Query query) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (Func.isNotEmpty(stationRelation.getStationCode())) { + wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode()); + } + if (Func.isNotEmpty(stationRelation.getDeviceCode())) { + wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()); + } + wrapper.eq(StationRelation::getIsDeleted, 0); + return this.page(Condition.getPage(query), wrapper); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index aa58a0f..6b85aa8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -25,6 +25,7 @@ import com.hnac.hzims.operational.station.mapper.StationMapper; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationPushConfigService; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.station.vo.HomeMapStationVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationPushConfigVO; import com.hnac.hzims.operational.station.vo.StationVO; @@ -776,4 +777,31 @@ public class StationServiceImpl extends BaseServiceImpl homeMapStationVo() { + List stations = this.list(Wrappers.lambdaQuery() + .isNotNull(StationEntity::getRefDept) + .isNotNull(StationEntity::getAreaCode) + ); + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + return stations.stream().map(o->{ + HomeMapStationVo mapStation = new HomeMapStationVo(); + mapStation.setAreaCode(o.getAreaCode()); + mapStation.setName(o.getName()); + mapStation.setCode(o.getCode()); + mapStation.setLttd(o.getLttd()); + mapStation.setLgtd(o.getLgtd()); + mapStation.setRefDept(o.getRefDept()); + mapStation.setIsAbroad(o.getIsAbroad()); + mapStation.setRefCountry(o.getRefCountry()); + return mapStation; + }).collect(Collectors.toList()); + } } diff --git a/hzims-service/operational/src/main/resources/db/2.0.5.sql b/hzims-service/operational/src/main/resources/db/2.0.5.sql new file mode 100644 index 0000000..01b2814 --- /dev/null +++ b/hzims-service/operational/src/main/resources/db/2.0.5.sql @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS `station_relation`; +CREATE TABLE `station_relation` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `station_code` varchar(200) DEFAULT NULL COMMENT '站点编码', + `device_code` varchar(128) DEFAULT NULL COMMENT '设备编码', + `send_warning` int(11) DEFAULT '0' COMMENT '当日是否发送预警', + `send_soe` int(11) DEFAULT '0' COMMENT '当日是否发送告警', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + `is_deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除', + `low_soe_user_id` varchar(20) DEFAULT NULL COMMENT '低级告警负责人id', + `low_soe_phone` varchar(20) DEFAULT NULL COMMENT '低级告警电话号码', + `middle_soe_user_id` varchar(20) DEFAULT NULL COMMENT '中级告警负责人id', + `middle_soe_phone` varchar(20) DEFAULT NULL COMMENT '中级告警电话号码', + `high_soe_user_id` varchar(20) DEFAULT NULL COMMENT '高级告警负责人id', + `high_soe_phone` varchar(20) DEFAULT NULL COMMENT '高级告警电话号码', + `flow_value` double(12,3) DEFAULT NULL COMMENT '核定流量', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='站点和霍山生态流量电站的关联关系表'; \ No newline at end of file From 4c1eb9c1d2af572fa5a37b60428f6f439679f66b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 10:53:32 +0800 Subject: [PATCH 087/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/fill/feign/IGenerateClient.java | 26 +++++++++++++++ .../fill/feign/IGenerateClientFallback.java | 15 +++++++++ .../controller/InteractiveController.java | 9 +++++ .../interactive/service/IInteractiveService.java | 2 ++ .../service/impl/InteractiveServiceImpl.java | 31 ++++++++++++++++++ .../operational/fill/feign/GenerateClient.java | 38 ++++++++++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java new file mode 100644 index 0000000..d73fa37 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.hnac.hzims.operational.OperationalConstants; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = IGenerateClientFallback.class +) +public interface IGenerateClient { + + String API_PREFIX = "/feign/generate/"; + + String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime"; + + + @GetMapping(STATION_GENERATE_BY_TIME) + Double stationGenerateByTime(@RequestParam("stationId") String stationId, + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java new file mode 100644 index 0000000..da7c067 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.fill.feign; + +import org.springframework.stereotype.Component; + +/** + * @author hx + */ +@Component +public class IGenerateClientFallback implements IGenerateClient { + + @Override + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + return 0.0; + } +} 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 40e79b3..472d092 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 @@ -77,4 +77,13 @@ public class InteractiveController { public R sendRemoteControl(@RequestBody ControlDTO operate) { return interactiveService.sendRemoteControl(operate); } + + @ApiOperation("站点发电量") + @ApiOperationSupport(order = 7) + @RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST}) + public R generation(@RequestParam @ApiParam("站点编号") String stationId, + @RequestParam @ApiParam("开始时间") String startTime, + @RequestParam @ApiParam("结束时间")String endTime) { + return R.data(interactiveService.generation(stationId,startTime,endTime) + "kwh"); + } } 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 2f6588a..acdcb37 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 @@ -43,4 +43,6 @@ public interface IInteractiveService { R knowledgeAsk(String question, String sessionId, String userId, String knowledge); R sendRemoteControl(ControlDTO operate); + + Double generation(String stationId, String startTime, String endTime); } 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 f5571dd..7ba145b 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 @@ -14,6 +14,9 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.operational.fill.feign.IGenerateClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,6 +57,10 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IRemoteClient remoteClient; + private final IStationClient stationClient; + + private final IGenerateClient generateClient; + private final IJumpPageService jumpPageService; private final IParamsService paramsService; @@ -277,4 +284,28 @@ public class InteractiveServiceImpl implements IInteractiveService { public R sendRemoteControl(ControlDTO operate) { return remoteClient.sendCtrl(operate); } + + /** + * 站点发电量 + * @param stationId + * @param startTime + * @param endTime + * @return + */ + @Override + public Double generation(String stationId, String startTime, String endTime) { + // 步骤1.查询站点 + R station = stationClient.getStationByCode(stationId); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + return 0.0; + } + // 步骤2.查询填报发电量 + double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); + + // 步骤3.查询设备 + + // 步骤4.遍历设备查询发电量 + + return fill; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java new file mode 100644 index 0000000..54e86ac --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.fill.service.GenerateService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * @author ysj + */ +@RestController +@Slf4j +@AllArgsConstructor +public class GenerateClient implements IGenerateClient { + + private final GenerateService generateService; + + @Override + @GetMapping(STATION_GENERATE_BY_TIME) + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + List generates = generateService.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,stationId) + .ge(GenerateEntity::getFillDate,startTime) + .le(GenerateEntity::getGenerate,endTime) + ); + if(CollectionUtil.isEmpty(generates)){ + return 0.0; + } + return generates.stream().mapToDouble(GenerateEntity::getGenerate).sum(); + } +} From 3b2f2da88c20a4c1e0e973775a48445ac3a6dc9d Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 11:35:59 +0800 Subject: [PATCH 088/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/feign/IEmInfoClient.java | 7 ++ .../hzims/equipment/feign/IEmInfoClientBack.java | 6 ++ .../hnac/hzims/equipment/feign/EmInfoClient.java | 6 ++ .../hnac/hzims/equipment/mapper/EmParamMapper.java | 1 + .../hnac/hzims/equipment/mapper/EmParamMapper.xml | 9 ++ .../hzims/equipment/service/IEmInfoService.java | 2 + .../hzims/equipment/service/IEmParamService.java | 1 + .../equipment/service/impl/EmInfoServiceImpl.java | 47 +++++++++++ .../equipment/service/impl/EmParamServiceImpl.java | 5 ++ .../controller/InteractiveController.java | 10 +-- .../service/impl/InteractiveServiceImpl.java | 96 ++++++++++++++++++++-- .../main/service/IAnalyseDataService.java | 5 +- .../main/service/impl/AnalyseDataServiceImpl.java | 61 +++++++++++++- 13 files changed, 241 insertions(+), 15 deletions(-) diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 6e6dec3..df356ed 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -19,6 +19,7 @@ package com.hnac.hzims.equipment.feign; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; import org.springframework.cloud.openfeign.FeignClient; @@ -84,6 +85,9 @@ public interface IEmInfoClient { String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; String EM_INFO_LIST = API_PREFIX + "/emInfoList"; + String RIDE_DEVICES = API_PREFIX + "/rideDevices"; + + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -169,4 +173,7 @@ public interface IEmInfoClient { @GetMapping(EM_INFO_LIST) R> emInfoList(EmInfoEntity req); + + @GetMapping(RIDE_DEVICES) + List rideDevices(List longs); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index c411e7e..104d494 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -2,6 +2,7 @@ package com.hnac.hzims.equipment.feign; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; @@ -114,4 +115,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public R> emInfoList(EmInfoEntity req) { return R.fail("远程调用失败"); } + + @Override + public List rideDevices(List longs) { + return new ArrayList<>(); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 637da20..444b59c 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -9,6 +9,7 @@ import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; @@ -155,6 +156,11 @@ public class EmInfoClient implements IEmInfoClient { return R.data(service.list(queryWrapper)); } + @Override + public List rideDevices(List deptIds) { + return service.rideDevices(deptIds); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java index a2cb335..0e83b71 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java @@ -19,4 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper { List selectRideCountGroupEmIdByDepts(@Param("list") List list); + List rides(List deviceIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml index bf699b0..09861ea 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml @@ -53,4 +53,13 @@ 'installedCapacity') + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index ead9dee..5632b61 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -98,4 +98,6 @@ public interface IEmInfoService extends BaseService { List select(Long deptId); List getEmInfoTree(EmInfoEntity req); + + List rideDevices(List deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java index 9284338..ca087ff 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java @@ -19,4 +19,5 @@ public interface IEmParamService extends BaseService { Map> getRideCountGroupEmIdByDepts(List emIds); + List rides(List deviceIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index fb6fb04..75d0db5 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -949,4 +949,51 @@ public class EmInfoServiceImpl extends BaseServiceImpl rideDevices(List deptIds) { + // 查询设备 + List devices = this.list(Wrappers.lambdaQuery() + .in(EmInfoEntity::getDepartment,deptIds) + .eq(EmInfoEntity::getHomePageDisplay,"1") + .eq(EmInfoEntity::getEmType,"2") + ); + if(CollectionUtil.isEmpty(devices)){ + return new ArrayList<>(); + } + List paramList = paramService.rides(devices.stream().map(EmInfoEntity::getId).collect(Collectors.toList())); + return devices.stream().map(device->{ + RideDeviceVo rideDevice = new RideDeviceVo(); + BeanUtil.copyProperties(device,rideDevice); + // 寻找设备配置参数 + List itemParamList = paramList.stream().filter(o->device.getId().equals(o.getInfoId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(itemParamList)) { + // 遍历设备配置参数 + for (EmParamEntity paramEntity : itemParamList) { + String paramName = paramEntity.getParamName(); + switch (paramName) { + case "ct": + case "CT": + rideDevice.setCt(Double.parseDouble(paramEntity.getParamValue())); + break; + case "pt": + case "PT": + rideDevice.setPt(Double.parseDouble(paramEntity.getParamValue())); + break; + default: + break; + } + } + // 设置ct * pt + if (null != rideDevice.getCt() && null != rideDevice.getPt()) { + rideDevice.setRide(rideDevice.getCt() * rideDevice.getPt()); + }else{ + rideDevice.setRide(1.0); + } + }else{ + rideDevice.setRide(1.0); + } + return rideDevice; + }).collect(Collectors.toList()); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java index 394189f..cd4f0c6 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java @@ -69,4 +69,9 @@ public class EmParamServiceImpl extends BaseServiceImpl rides(List deviceIds) { + return this.baseMapper.rides(deviceIds); + } } 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 472d092..bf68a91 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 @@ -1,6 +1,5 @@ package com.hnac.hzims.bigmodel.interactive.controller; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; @@ -8,7 +7,6 @@ import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; @@ -16,9 +14,7 @@ import org.springblade.core.tool.api.R; import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; +import java.text.DecimalFormat; /** * @Author: huangxing @@ -84,6 +80,8 @@ public class InteractiveController { public R generation(@RequestParam @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("开始时间") String startTime, @RequestParam @ApiParam("结束时间")String endTime) { - return R.data(interactiveService.generation(stationId,startTime,endTime) + "kwh"); + double generate = interactiveService.generation(stationId,startTime,endTime); + DecimalFormat format = new DecimalFormat("0.00"); + return R.data(format.format(generate) + "kwh"); } } 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 7ba145b..93730b0 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 @@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; @@ -14,19 +15,26 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import com.hnac.hzims.operational.fill.feign.IGenerateClient; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; 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.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; @@ -38,7 +46,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.*; import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; @@ -55,6 +66,8 @@ public class InteractiveServiceImpl implements IInteractiveService { private final BladeLogger logger; + private final IEmInfoClient deviceClient; + private final IRemoteClient remoteClient; private final IStationClient stationClient; @@ -73,8 +86,12 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; + private final IAnalyseDataSearchClient analyseDataSearchClient; + private final ExtraResolveStrategyService extraResolveStrategyService; + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); + @Value("${fdp.host}") private String fdpHost; @@ -303,9 +320,78 @@ public class InteractiveServiceImpl implements IInteractiveService { double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); // 步骤3.查询设备 + List devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept())); + if(CollectionUtil.isEmpty(devices)){ + return fill; + } // 步骤4.遍历设备查询发电量 + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + List deviceGenerate = new CopyOnWriteArrayList(); + for(RideDeviceVo device : devices){ + pool.submit(()->{ + deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER)); + }); + countDownLatch.countDown(); + } + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum(); + } - return fill; + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param ride 配电比 + * @param signages 指标 + * @return + */ + private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return 0.0; + } + List records = result.getData(); + if(CollectionUtil.isEmpty(records)){ + return 0.0; + } + AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); + if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { + return 0.0; + } + List analyseDataTaosVOList = analyzeDataConditionVO.getList(); + if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { + return 0.0; + } + AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); + if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { + return 0.0; + } + return Double.parseDouble(analyseDataTaosVO.getVal()) * ride; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java index 14d1292..fe2130f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java @@ -15,10 +15,13 @@ public interface IAnalyseDataService { List getAnalyzeCodeBySignages(Function convert, T resource); + List analyzeCodeBySignages(List list); + + List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages); List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); List periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List deviceCodes, String signages); - Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java index 927d6d2..865f0e8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java @@ -22,7 +22,10 @@ import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -47,6 +50,58 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { return result; } + /** + * 查询设备实例属性标识 + * @param list + * @return + */ + @Override + public List analyzeCodeBySignages(List list) { + R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param signages 指标集合 + * @return + */ + @Override + public List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + signages.forEach(signage->{ + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + analyzeDataConditionPO.setSignages(signage); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + }); + po.setSignboardConditions(signboardConditions); + log.error("period_targets_data_request {}",po); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + log.error("period_targets_data_resp {}",result); + return result.getData(); + } + /*** * 指标数据列表查询 * @param startTime 开始时间 @@ -134,7 +189,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { * @return */ @Override - public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { + public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); List signboardConditions = new ArrayList<>(); AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); @@ -170,7 +225,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { return 0f; } - return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; + return Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * ride)) ; } From 1c0aec87e2365ed27364621f3b1e736896852c15 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 25 May 2024 11:37:51 +0800 Subject: [PATCH 089/151] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/vo/AttrSelectionVO.java | 14 ++++++ .../hzims/bigmodel/interactive/vo/DataItemVO.java | 39 ++++++++++++++++ .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 32 +++++++++++++ .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 ++++++++ .../operational/station/feign/IStationClient.java | 5 +- .../station/feign/IStationClientFallBack.java | 5 ++ .../interactive/constants/FuncRouteEnum.java | 1 + .../constants/SearchStationTypeEnum.java | 39 ++++++++++++++++ .../interactive/constants/SearchTypeEnum.java | 28 ++++++++++++ .../controller/InteractiveController.java | 7 +++ .../interactive/service/IInteractiveService.java | 3 ++ .../service/impl/ExtraResolveStrategyService.java | 49 ++++++++++++++++---- .../service/impl/InteractiveServiceImpl.java | 53 ++++++++++++++++++++++ .../hzims/bigmodel/interactive/vo/DataItemVO.java | 39 ---------------- .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 32 ------------- .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 -------- .../operational/station/feign/StationClient.java | 13 ++++++ 17 files changed, 299 insertions(+), 100 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java new file mode 100644 index 0000000..67f0011 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 15:55 + */ +@Data +public class AttrSelectionVO extends SelectionVO implements Serializable { + private DataItemVO item; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java new file mode 100644 index 0000000..914f25b --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:20 + */ +@Data +public class DataItemVO implements Serializable { + + private String name; + + @JSONField(name = "id") + private String attrId; + + @JSONField(name = "param_name") + private String attrName; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "device_id") + private String deviceId; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String units; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java new file mode 100644 index 0000000..1f2fcfd --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:28 + */ +@Data +public class DataVO implements Serializable { + + /**数据查询类型:实时、历史**/ + private String type; + + @JSONField(name = "time_begin") + private String startTime; + + @JSONField(name = "time_end") + private String endTime; + + /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ + private String method; + + /**实时数据结果集**/ + private RealDataVO real; + + private DataItemVO item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java new file mode 100644 index 0000000..16a5a46 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 10:26 + */ +@Data +public class RealDataVO implements Serializable { + + private String time; + + private String value; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index cc8856a..8574363 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -30,7 +30,7 @@ public interface IStationClient { String LIST = API_PREFIX + "/list"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; - + String GET_STATIONS_BY_TYPE_AND_DURATION = "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; @GetMapping(GET_LIST_ALL) @@ -81,4 +81,7 @@ public interface IStationClient { */ @PostMapping(QUERY_STATION_BY_CODES) R> querySatationByCodes(@RequestParam("codes") List codes); + + @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) + R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java index 5c0aca1..eeb90e5 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java @@ -76,4 +76,9 @@ public class IStationClientFallBack implements IStationClient { public R> querySatationByCodes(List codes) { return R.data(new ArrayList<>()); } + + @Override + public R> getStationByTypeAndDuration(String startTime, String endTime, String type) { + return R.fail("远程调用失败!"); + } } 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 4b1d359..8ce75d0 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 @@ -21,6 +21,7 @@ public enum FuncRouteEnum { CHOOSE_FAULT("choose_fault","选择故障",null), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), + CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE) ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java new file mode 100644 index 0000000..15be73a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:14 + */ +@AllArgsConstructor +public enum SearchStationTypeEnum { + TOTAL("站点总数量",null), + HYDROPOWER_TOTAL("水电站总数量","0"), + WIND_POWER_TOTAL("风电场总数量","1"), + ENERGY_STORAGE_TOTAL("储能站总数量","3"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), + CHARGE_TOTAL("充电站总数量","7"), + HYDROPOWER_NUM("水电站接入量","0"), + WIND_POWER_NUM("风电场接入量","1"), + ENERGY_STORAGE_NUM("储能站接入量","3"), + PHOTOVOLTAIC_NUM("光伏站接入量","5"), + CHARGE_NUM("充电站接入量","7"), + ; + + @Getter + private String searchStationType; + @Getter + private String stationType; + + public static SearchStationTypeEnum getTypeEnum(String searchStationType) { + return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchStationType().equals(searchStationType)) + .findFirst() + .orElse(null); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java new file mode 100644 index 0000000..0692d62 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:13 + */ +@AllArgsConstructor +public enum SearchTypeEnum { + REAL("实时"), + HISTORY("历史") + ; + @Getter + private String searchType; + + public static SearchTypeEnum getSearchType(String searchType) { + return Arrays.stream(SearchTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchType().equals(searchType)) + .findFirst() + .orElse(null); + } + +} 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 40e79b3..9fbb0b2 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 @@ -77,4 +77,11 @@ public class InteractiveController { public R sendRemoteControl(@RequestBody ControlDTO operate) { return interactiveService.sendRemoteControl(operate); } + + @ApiOperation("解析接入站点数量") + @ApiOperationSupport(order = 7) + @PostMapping("/resolveStations") + public R resolveStations(String startTime,String endTime,String type,String enumType) { + return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); + } } 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 2f6588a..d37d0cf 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import org.springblade.core.tool.api.R; import org.springblade.system.dto.ControlDTO; @@ -14,6 +15,8 @@ import java.util.Map; */ public interface IInteractiveService { + ExtraVO resolveStations(String startTime, String endTime, String type, String enumType); + R resolve(ModelFunctionReq req); R ask(String question,String sessionId,String userId); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 9502fec..4143a10 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -12,15 +12,14 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.dto.ControlDTO; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -45,6 +44,7 @@ public class ExtraResolveStrategyService { private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; private final DeviceClient deviceClient; + private final BladeLogger logger; private final RedisTemplate redisTemplate; /** @@ -74,6 +74,8 @@ public class ExtraResolveStrategyService { return this.resolveConfirmRemote(extra); case SHOW_PARAM: return this.resolveShowParam(extra); + case CHOOSE_YC: + return this.resolveChooseYc(extra); default: break; } @@ -82,16 +84,47 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveChooseYc(JSONObject extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("ycs")) { + List attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class); + result.setSelection(attrs); + } + result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode()); + result.setSpecial(true); + result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); + return result; + } + private ExtraVO resolveShowParam(Map extra) { ExtraVO result = new ExtraVO(); result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); Map param = new HashMap(1); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); - if(Func.isNotEmpty(data) && Func.isNotEmpty(data.getReal()) && Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { - RealDataVO real = data.getReal(); - Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); - real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + if(Func.isNotEmpty(data)) { + if(Func.isNotEmpty(data.getReal())) { + if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { + RealDataVO real = data.getReal(); + Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); + real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + } + } + if(Func.isNotEmpty(data.getItem())) { + if("历史".equals(data.getType())) { + // 历史数据需要手动查询功能ID供前端使用 + DataItemVO item = data.getItem(); + R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); + if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { + List attrList = attrR.getData(); + Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) + .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); + logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); + item.setAttrId(facDeviceIdOptional.orElse(null)); + } + } + } } param.put("data", data); result.setParams(param); 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 f5571dd..ba34e33 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 @@ -9,11 +9,17 @@ import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum; +import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -66,12 +72,59 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; + private final IStationClient stationClient; + private final ExtraResolveStrategyService extraResolveStrategyService; @Value("${fdp.host}") private String fdpHost; @Override + public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) { + ExtraVO extraVO = new ExtraVO(); + extraVO.setType(TypeEnum.PARAMS.getType()); + extraVO.setFuncCode("stations_num"); + String stationType = ""; + SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); + if(SearchTypeEnum.REAL.getSearchType().equals(type)) { + startTime = null; + endTime = null; + } + else { + switch(stationTypeEnum) { + case HYDROPOWER_TOTAL: + case WIND_POWER_TOTAL: + case ENERGY_STORAGE_TOTAL: + case PHOTOVOLTAIC_TOTAL: + case CHARGE_TOTAL: + stationType = stationTypeEnum.getStationType(); + startTime = null; + break; + case HYDROPOWER_NUM: + case WIND_POWER_NUM: + case ENERGY_STORAGE_NUM: + case PHOTOVOLTAIC_NUM: + case CHARGE_NUM: + stationType = stationTypeEnum.getStationType(); + break; + default: + throw new ServiceException("未查询到相关"); + } + } + R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); + Assert.isTrue(stationListR.isSuccess(),() -> { + throw new ServiceException("获取接入站点数量失败!"); + }); + Map params = new HashMap<>(); + params.put("searchStationType",stationTypeEnum.getSearchStationType()); + params.put("num",stationTypeEnum.getSearchStationType()); + params.put("startTime",startTime); + params.put("endTime",endTime); + extraVO.setParams(params); + return extraVO; + } + + @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java deleted file mode 100644 index 914f25b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:20 - */ -@Data -public class DataItemVO implements Serializable { - - private String name; - - @JSONField(name = "id") - private String attrId; - - @JSONField(name = "param_name") - private String attrName; - - @JSONField(name = "device_name") - private String deviceName; - - @JSONField(name = "device_id") - private String deviceId; - - @JSONField(name = "station_id") - private String projectId; - - @JSONField(name = "station_name") - private String projectName; - - private String signage; - - private String units; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java deleted file mode 100644 index 1f2fcfd..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:28 - */ -@Data -public class DataVO implements Serializable { - - /**数据查询类型:实时、历史**/ - private String type; - - @JSONField(name = "time_begin") - private String startTime; - - @JSONField(name = "time_end") - private String endTime; - - /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ - private String method; - - /**实时数据结果集**/ - private RealDataVO real; - - private DataItemVO item; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java deleted file mode 100644 index 16a5a46..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Data; -import org.springblade.core.tool.utils.DateUtil; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/24 10:26 - */ -@Data -public class RealDataVO implements Serializable { - - private String time; - - private String value; - -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index e9cf868..fbefca8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -14,6 +14,7 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -137,6 +138,18 @@ public class StationClient implements IStationClient { .in(StationEntity::getCode,codes))); } + @Override + @GetMapping("/getStationByTypeAndDuration") + public R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime, + @RequestParam(required = false) String endTime, + @RequestParam(required = false) String type) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime) + .ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime); + return R.data(stationService.list(wrapper)); + } + @Override @PostMapping("/getStationByCodeOrRedDept") From 90b431a7b31bd50c30085d0ac9f7c3f32de78787 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 12:08:03 +0800 Subject: [PATCH 090/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/hzims-big-model/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index cedb16a..91ae6d1 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -75,6 +75,10 @@ com.hnac.hzinfo.data hzinfo-data-sdk + + com.hnac.hzims + equipment-api + From b74c3296c3f2d4ec5414e40b5310490637420aad Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 25 May 2024 18:46:28 +0800 Subject: [PATCH 091/151] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/station/feign/IStationClient.java | 4 +- .../constants/SearchStationTypeEnum.java | 24 ++++++----- .../controller/InteractiveController.java | 5 ++- .../service/impl/ExtraResolveStrategyService.java | 3 ++ .../service/impl/InteractiveServiceImpl.java | 50 +++++----------------- .../bigmodel/interactive/vo/StationSearchVO.java | 24 +++++++++++ .../bigmodel/schedule/InteractiveSchedule.java | 18 +++----- .../bigmodel/schedule/XxlJobHandlerConstant.java | 4 +- 8 files changed, 65 insertions(+), 67 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index 8574363..28019bd 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -30,7 +30,7 @@ public interface IStationClient { String LIST = API_PREFIX + "/list"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; - String GET_STATIONS_BY_TYPE_AND_DURATION = "/getStationByTypeAndDuration"; + String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; @GetMapping(GET_LIST_ALL) @@ -83,5 +83,5 @@ public interface IStationClient { R> querySatationByCodes(@RequestParam("codes") List codes); @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) - R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); + R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java index 15be73a..51ce3a1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -11,23 +11,25 @@ import java.util.Arrays; */ @AllArgsConstructor public enum SearchStationTypeEnum { - TOTAL("站点总数量",null), - HYDROPOWER_TOTAL("水电站总数量","0"), - WIND_POWER_TOTAL("风电场总数量","1"), - ENERGY_STORAGE_TOTAL("储能站总数量","3"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), - CHARGE_TOTAL("充电站总数量","7"), - HYDROPOWER_NUM("水电站接入量","0"), - WIND_POWER_NUM("风电场接入量","1"), - ENERGY_STORAGE_NUM("储能站接入量","3"), - PHOTOVOLTAIC_NUM("光伏站接入量","5"), - CHARGE_NUM("充电站接入量","7"), + TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"), ; @Getter private String searchStationType; @Getter private String stationType; + @Getter + private String label; public static SearchStationTypeEnum getTypeEnum(String searchStationType) { return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) 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 03dd26e..0771fba 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 @@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -77,8 +78,8 @@ public class InteractiveController { @ApiOperation("解析接入站点数量") @ApiOperationSupport(order = 7) @PostMapping("/resolveStations") - public R resolveStations(String startTime,String endTime,String type,String enumType) { - return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); + public R resolveStations(@RequestBody StationSearchVO req) { + return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType())); } @ApiOperation("站点发电量") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 4143a10..ed8ffff 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -81,6 +81,9 @@ public class ExtraResolveStrategyService { } } } + else if(extra.containsKey("extra")){ + return extra.getObject("extra",ExtraVO.class); + } return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } 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 516c5ea..bfe3f2d 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 @@ -22,7 +22,7 @@ import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.equipment.feign.IEmInfoClient; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; + import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.RideDeviceVo; import com.hnac.hzims.operational.fill.feign.IGenerateClient; import com.hnac.hzims.operational.main.constant.HomePageConstant; @@ -92,8 +92,6 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; - private final IStationClient stationClient; - private final IAnalyseDataSearchClient analyseDataSearchClient; private final ExtraResolveStrategyService extraResolveStrategyService; @@ -108,40 +106,23 @@ public class InteractiveServiceImpl implements IInteractiveService { ExtraVO extraVO = new ExtraVO(); extraVO.setType(TypeEnum.PARAMS.getType()); extraVO.setFuncCode("stations_num"); - String stationType = ""; + String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(SearchTypeEnum.REAL.getSearchType().equals(type)) { - startTime = null; - endTime = null; + if(!startTime.equals(endTime)) { + label = String.format("自%s到%s时间为止,",startTime,endTime); } else { - switch(stationTypeEnum) { - case HYDROPOWER_TOTAL: - case WIND_POWER_TOTAL: - case ENERGY_STORAGE_TOTAL: - case PHOTOVOLTAIC_TOTAL: - case CHARGE_TOTAL: - stationType = stationTypeEnum.getStationType(); - startTime = null; - break; - case HYDROPOWER_NUM: - case WIND_POWER_NUM: - case ENERGY_STORAGE_NUM: - case PHOTOVOLTAIC_NUM: - case CHARGE_NUM: - stationType = stationTypeEnum.getStationType(); - break; - default: - throw new ServiceException("未查询到相关"); - } + startTime = null; + endTime = null; + label = "目前"; } - R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); + R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType()); Assert.isTrue(stationListR.isSuccess(),() -> { throw new ServiceException("获取接入站点数量失败!"); }); Map params = new HashMap<>(); params.put("searchStationType",stationTypeEnum.getSearchStationType()); - params.put("num",stationTypeEnum.getSearchStationType()); + params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size())); params.put("startTime",startTime); params.put("endTime",endTime); extraVO.setParams(params); @@ -192,18 +173,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } private void addQuestionSessionId(String sessionId) { - // 添加redis问题会话 - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - List asks = Collections.singletonList(sessionId); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - }else{ - List asks = JSONObject.parseArray(json.toString(),String.class); - if(!asks.contains(sessionId)){ - asks.add(sessionId); - } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - } + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java new file mode 100644 index 0000000..d111b70 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/25 14:03 + */ +@Data +public class StationSearchVO implements Serializable { + + private String startTime; + + private String endTime; + + @NotBlank(message = "查询类型不能为空") + private String type; + + private String enumType; + +} 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 85affae..e145733 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 @@ -23,6 +23,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; @@ -90,12 +91,7 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!"); - return ReturnT.SUCCESS; - } - List sessionIds = JSONObject.parseArray(json.toString(),String.class); + List sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); if(CollectionUtil.isEmpty(sessionIds)){ XxlJobLogger.log("问题都已经回答完毕!"); return ReturnT.SUCCESS; @@ -106,13 +102,13 @@ public class InteractiveSchedule { if(sessionIds.contains(answerVO.getSessionId())){ WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } } - // 问题回答完成,去除redis问题标记 - if(answerVO.getRunning() == 0){ - sessionIds.remove(answerVO.getSessionId()); + if(answerVO.getRunning() == 0) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index 7317f54..0f210b7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -1,5 +1,7 @@ package com.hnac.hzims.bigmodel.schedule; +import com.hnac.hzims.common.constant.CommonConstant; + /** * @Author: huangxing * @Date: 2024/04/28 16:19 @@ -18,6 +20,6 @@ public interface XxlJobHandlerConstant { String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; - String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key"; } From 4eb705f531fc2b26c808b9f077968cec30d1cd34 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sun, 26 May 2024 11:25:38 +0800 Subject: [PATCH 092/151] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExtraResolveStrategyService.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index ed8ffff..60d910d 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -114,20 +114,20 @@ public class ExtraResolveStrategyService { real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); } } - if(Func.isNotEmpty(data.getItem())) { - if("历史".equals(data.getType())) { - // 历史数据需要手动查询功能ID供前端使用 - DataItemVO item = data.getItem(); - R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); - if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { - List attrList = attrR.getData(); - Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) - .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); - logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); - item.setAttrId(facDeviceIdOptional.orElse(null)); - } - } - } +// if(Func.isNotEmpty(data.getItem())) { +// if("历史".equals(data.getType())) { +// // 历史数据需要手动查询功能ID供前端使用 +// DataItemVO item = data.getItem(); +// R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); +// if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { +// List attrList = attrR.getData(); +// Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) +// .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); +// logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); +// item.setAttrId(facDeviceIdOptional.orElse(null)); +// } +// } +// } } param.put("data", data); result.setParams(param); From b8ad77fa361d26fd2d53297116094df0f2449b98 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 08:13:30 +0800 Subject: [PATCH 093/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/feign/IEmInfoClient.java | 2 +- .../hnac/hzims/equipment/feign/EmInfoClient.java | 3 ++- .../hnac/hzims/equipment/mapper/EmParamMapper.java | 2 +- .../service/impl/InteractiveServiceImpl.java | 1 - .../fill/controller/GenerateController.java | 9 +++++++ .../operational/fill/feign/GenerateClient.java | 7 ++++-- .../operational/fill/service/GenerateService.java | 2 ++ .../fill/service/impl/GenerateServiceImpl.java | 28 ++++++++++++++++++---- 8 files changed, 44 insertions(+), 10 deletions(-) diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index df356ed..45145c9 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -175,5 +175,5 @@ public interface IEmInfoClient { R> emInfoList(EmInfoEntity req); @GetMapping(RIDE_DEVICES) - List rideDevices(List longs); + List rideDevices(@RequestParam("deptIds") List deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 444b59c..de29497 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -157,7 +157,8 @@ public class EmInfoClient implements IEmInfoClient { } @Override - public List rideDevices(List deptIds) { + @GetMapping(RIDE_DEVICES) + public List rideDevices(@RequestParam("deptIds") List deptIds) { return service.rideDevices(deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java index 0e83b71..7244763 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java @@ -19,5 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper { List selectRideCountGroupEmIdByDepts(@Param("list") List list); - List rides(List deviceIds); + List rides(@Param("deviceIds") List deviceIds); } 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 bfe3f2d..8041056 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 @@ -347,7 +347,6 @@ public class InteractiveServiceImpl implements IInteractiveService { if(CollectionUtil.isEmpty(devices)){ return fill; } - // 步骤4.遍历设备查询发电量 // 监控线程执行完后返回结果 CountDownLatch countDownLatch = new CountDownLatch(devices.size()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java index abe2ff8..54b5591 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java @@ -80,4 +80,13 @@ public class GenerateController extends BladeController { return service.pageCondition(filter, query); } + /** + * 新增 + */ + @PostMapping("/test") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "测试发电量保存", notes = "传入InsertPowerEntity对象") + public R test(@RequestBody GenerateEntity entity) { + return R.status(service.test(entity)); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java index 54e86ac..a017445 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -7,6 +7,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -24,11 +25,13 @@ public class GenerateClient implements IGenerateClient { @Override @GetMapping(STATION_GENERATE_BY_TIME) - public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + public Double stationGenerateByTime(@RequestParam("stationId") String stationId, + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime) { List generates = generateService.list(Wrappers.lambdaQuery() .eq(GenerateEntity::getStationCode,stationId) .ge(GenerateEntity::getFillDate,startTime) - .le(GenerateEntity::getGenerate,endTime) + .le(GenerateEntity::getFillDate,endTime) ); if(CollectionUtil.isEmpty(generates)){ return 0.0; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java index 699bd03..fa68b8a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java @@ -37,4 +37,6 @@ public interface GenerateService extends BaseService { List generateThreeYear(String start, String end, String station); List fillPowerMon(String code); + + boolean test(GenerateEntity entity); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index bc33c70..88fc4f4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -26,10 +26,7 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -246,6 +243,29 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ + entity.setId(null); + entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); + entity.setGenerate((random.nextDouble() * 10000) + 50000); + this.save(entity); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + } + return true; + } + /** * 获取近年月份集合 From eb8d326b6ca9f81f814cd053672b6d3678f05e32 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 08:49:22 +0800 Subject: [PATCH 094/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/controller/InteractiveController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0771fba..c109e57 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 @@ -90,6 +90,6 @@ public class InteractiveController { @RequestParam @ApiParam("结束时间")String endTime) { double generate = interactiveService.generation(stationId,startTime,endTime); DecimalFormat format = new DecimalFormat("0.00"); - return R.data(format.format(generate) + "kwh"); + return R.data(format.format(generate) + "kWh"); } } From ce28eac1b62e611a3558e55f16bb5e3bb3a206a0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 27 May 2024 09:15:58 +0800 Subject: [PATCH 095/151] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/SearchStationTypeEnum.java | 25 ++++++++++++---------- .../websocket/handler/InteractiveHandler.java | 14 ++++++++++++ .../operational/station/feign/StationClient.java | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java index 51ce3a1..ea935c1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -11,17 +11,20 @@ import java.util.Arrays; */ @AllArgsConstructor public enum SearchStationTypeEnum { - TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"), - HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"), - WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"), - ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"), - CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"), - HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"), - WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"), - ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"), - PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"), - CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"), + STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"), + SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"), + STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"), + SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"), ; @Getter 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 23b8d2e..c8a5ce8 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 @@ -117,6 +117,8 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_FAULT: this.handleFaultChoose(messageContext,sessionId); break; + case CHOOSE_YC: + this.handleDataChoose(messageContext,sessionId); default: break; } @@ -209,4 +211,16 @@ public class InteractiveHandler extends TextWebSocketHandler { extra.put("data",data); interactiveService.specialAsk(sessionId,userId,extra); } + + private void handleDataChoose(JSONObject messageContext,String sessionId) { + IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + String userId = messageContext.getString("userId"); + String funcCode = messageContext.getString("funcCode"); + FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); + Map extra = new HashMap<>(2); + extra.put("func",funcCode); + extra.put("data",selectionVO); + interactiveService.specialAsk(sessionId,userId,extra); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index fbefca8..b2ca924 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -144,7 +144,7 @@ public class StationClient implements IStationClient { @RequestParam(required = false) String endTime, @RequestParam(required = false) String type) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) + .eq(StringUtil.isNotBlank(type) && Func.isNotEmpty(type),StationEntity::getType, type) .le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime) .ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime); return R.data(stationService.list(wrapper)); From 3f0e049e33e948c6b4cf7b040e6ad24a09b95372 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 09:23:50 +0800 Subject: [PATCH 096/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 88fc4f4..9cf07ec 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -258,7 +258,7 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ entity.setId(null); entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); - entity.setGenerate((random.nextDouble() * 10000) + 50000); + entity.setGenerate((random.nextDouble() * 2800) + 12000); this.save(entity); calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); From afbab4cc47234542f80f6a0e24717f946e377a20 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 14:45:51 +0800 Subject: [PATCH 097/151] =?UTF-8?q?#=E5=A1=AB=E6=8A=A5=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/operational/fill/feign/GenerateClient.java | 5 ++++- .../hzims/operational/fill/service/impl/GenerateServiceImpl.java | 2 +- .../hzims/operational/main/service/impl/HydropowerServiceImpl.java | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java index a017445..22030a1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -6,10 +6,12 @@ import com.hnac.hzims.operational.fill.service.GenerateService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; import java.util.List; @@ -28,9 +30,10 @@ public class GenerateClient implements IGenerateClient { public Double stationGenerateByTime(@RequestParam("stationId") String stationId, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) { + Date start = DateUtil.parse(startTime,DateUtil.PATTERN_DATETIME); List generates = generateService.list(Wrappers.lambdaQuery() .eq(GenerateEntity::getStationCode,stationId) - .ge(GenerateEntity::getFillDate,startTime) + .ge(GenerateEntity::getFillDate,DateUtil.format(start,DateUtil.PATTERN_DATE)) .le(GenerateEntity::getFillDate,endTime) ); if(CollectionUtil.isEmpty(generates)){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 9cf07ec..b3141e0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -258,7 +258,7 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ entity.setId(null); entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); - entity.setGenerate((random.nextDouble() * 2800) + 12000); + entity.setGenerate((random.nextDouble() * 1360) + 19000); this.save(entity); calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index cba31a3..98d399a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -631,6 +631,8 @@ public class HydropowerServiceImpl implements HydropowerService { // 年发电量 kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); // 月发电量 + + kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); // 日发电量 kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); From c8dcd995023c2c8448a92835e098faec36f66f8c Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 27 May 2024 16:36:34 +0800 Subject: [PATCH 098/151] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/HygieneTemplateDetailEntity.java | 8 ++++ .../safeproduct/controller/HygieneController.java | 4 +- .../service/IHygieneTemplateDetailService.java | 7 ++++ .../service/IHygieneTemplateService.java | 7 ++++ .../service/impl/HygienePlanServiceImpl.java | 43 +++++++++------------- .../impl/HygieneTemplateDetailServiceImpl.java | 13 +++++++ .../service/impl/HygieneTemplateServiceImpl.java | 33 ++++++++++++++++- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 18 +++++++++ .../safeproduct/src/main/resources/db/2.0.1.sql | 4 +- 9 files changed, 107 insertions(+), 30 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java index 9fe501f..3f3ff43 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java @@ -25,6 +25,14 @@ public class HygieneTemplateDetailEntity extends BaseEntity { @ApiModelProperty("责任区") private String zone; + @Size(max = 20, message = "责任人字段长度不能超过20") + @ApiModelProperty("责任人") + private String principal; + @ApiModelProperty("检查项") private String checkItem; + + @Size(max = 255, message = "检查项分值字段长度不能超过255") + @ApiModelProperty("检查项分值") + private String checkItemScore; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index e6c0c3e..fe2739c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -218,7 +218,7 @@ public class HygieneController extends BladeController { @ApiOperation(value = "卫生自查模板详情") @ApiOperationSupport(order = 18) @Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false) - public R hygieneTemplateDetail(@RequestParam Long id) { + public R hygieneTemplateDetail(@RequestParam Long id) { HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id); return R.data(detail); } @@ -227,7 +227,7 @@ public class HygieneController extends BladeController { @ApiOperation(value = "卫生自查模板分页") @ApiOperationSupport(order = 19) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) - public R hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { + public R> hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { IPage page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( param, HygieneTemplateEntity.class)); return R.data(page); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java index de71dad..463b0b5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java @@ -18,4 +18,11 @@ public interface IHygieneTemplateDetailService extends IService getListByTemplateId(Long templateId); + + /** + * 删除关联模板详情数据 + * @param templateId 模板id + * @return true-成功,false-失败 + */ + boolean removeReferenceDetail(Long templateId); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java index 71493f9..5f45e16 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java @@ -39,4 +39,11 @@ public interface IHygieneTemplateService extends IService * @return 详情 */ HygieneTemplateDetailVO getHygieneTemplateDetail(Long id); + + /** + * 根据模板名获取模板 + * @param name 模板名 + * @return 模板实体类 + */ + HygieneTemplateEntity getHygieneTemplateByName(String name); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index 2c3b176..fb4a3d3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.log.exception.ServiceException; @@ -126,7 +127,7 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); // 若计划修改成功,修改关联责任区数据 if (updatePlan) { - for (HygieneZoneEntity zone : zoneList) { - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - getSumScore(scores, hygienePlanDTO.getStandardScore()); + // 删除旧数据 + boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); + if (removeZone) { + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + // 增加新数据 + for (HygieneZoneEntity zone : zoneList) { + // 传计划id + if (hygienePlan != null) { + zone.setHygienePlanId(hygienePlan.getId()); + } + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); + } + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } - // 校验通过则批量修改责任区数据 - return R.status(hygieneZoneService.updateBatchById(zoneList)); } return R.status(Boolean.FALSE); } @@ -210,24 +221,6 @@ public class HygienePlanServiceImpl extends ServiceImpl standardScore) { - throw new ServiceException("累计分值超过标准总分值"); - } - } - if (sum < standardScore) { - throw new ServiceException("标准总分值未全部分配"); - } - } - - /** * 根据编码查询卫生自查计划 */ @Override diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java index 3ea4851..8df4088 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; /** * 卫生自查模板详情服务实现类 @@ -27,4 +28,16 @@ public class HygieneTemplateDetailServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId); + List list = this.list(queryWrapper); + List ids = list.stream().map(HygieneTemplateDetailEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java index efceb94..55f66bb 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper; import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.CollectionUtil; @@ -49,6 +50,15 @@ public class HygieneTemplateServiceImpl extends ServiceImpl detailList = hygieneTemplateDTO.getTemplateDetailList(); + detailList.forEach(detail -> { + detail.setTemplateId(hygieneTemplateEntity.getId()); + String[] scores = detail.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, 100); + }); return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); } @@ -72,9 +82,18 @@ public class HygieneTemplateServiceImpl extends ServiceImpl detailList = hygieneTemplateDTO.getTemplateDetailList(); + for (HygieneTemplateDetailEntity detail : detailList) { + String[] scores = detail.getCheckItemScore().split(",|,"); + BaseUtil.getSumScore(scores, 100); + } + return hygieneTemplateDetailService.saveBatch(detailList); } /** @@ -104,4 +123,14 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name); + return this.getOne(queryWrapper); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index da74c7f..76aada7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -395,4 +395,22 @@ public class BaseUtil { } return fileName; } + + /** + * 计算累计分值 + * @param scores 各项分值 + * @param standardScore 标准总分值 + */ + public static void getSumScore(String[] scores, Integer standardScore) { + int sum = 0; + for (String score : scores) { + sum += Integer.parseInt(score); + if (sum > standardScore) { + throw new ServiceException("累计分值超过标准总分值"); + } + } + if (sum < standardScore) { + throw new ServiceException("标准总分值未全部分配"); + } + } } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 3730612..9434144 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -31,7 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `check_item` mediumtext NOT NULL COMMENT '检查项', + `PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', + `CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', + `CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', From 2718da82c99eaf93a605895629bd4aeb82a9ad75 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 27 May 2024 16:37:00 +0800 Subject: [PATCH 099/151] =?UTF-8?q?update:=20message=E6=9C=8D=E5=8A=A1pom?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/message/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/hzims-service/message/pom.xml b/hzims-service/message/pom.xml index 2dcf390..7f5519f 100644 --- a/hzims-service/message/pom.xml +++ b/hzims-service/message/pom.xml @@ -88,7 +88,6 @@ org.springblade blade-system-api - 5.0.2-SNAPSHOT From bcc6592d3505b1f03d5911b63b48fb4b75007016 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 28 May 2024 11:24:00 +0800 Subject: [PATCH 100/151] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/mapper/HygienePlanMapper.java | 1 - .../service/impl/HygienePlanServiceImpl.java | 82 ++++++++++------------ .../service/impl/HygieneRecordServiceImpl.java | 14 ++-- .../service/impl/HygieneTemplateServiceImpl.java | 46 ++++++------ .../safeproduct/src/main/resources/db/2.0.1.sql | 6 +- 5 files changed, 75 insertions(+), 74 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java index 946d92b..8170e95 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - /** * 卫生自查计划Mapper类 * diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index fb4a3d3..4ad0ca5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -63,15 +63,16 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划新增成功,新增关联责任区数据 - if (savePlan) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); - } - // 校验通过则批量新增责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); } - return R.status(Boolean.FALSE); + // 校验通过则批量新增责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } /** @@ -153,28 +151,26 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划修改成功,修改关联责任区数据 - if (updatePlan) { - // 删除旧数据 - boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); - if (removeZone) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - // 增加新数据 - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); - } - // 校验通过则批量修改责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); - } + // 删除旧的责任区数据 + boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); + if (!removeZone) { + throw new ServiceException("删除旧的责任区数据失败"); + } + // 新增新的责任区数据 + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); } - return R.status(Boolean.FALSE); + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 24d3a9f..b38db24 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + // 重名校验 + HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setTemplateName(templateName); - boolean saveTemplate = this.save(hygieneTemplate); + // 新增模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setTemplateName(templateName); + boolean saveTemplate = this.save(hygieneTemplateEntity); if (!saveTemplate) { throw new ServiceException("卫生自查模板新增失败"); } - // 传模板id - HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName); + // 新增模板详情 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); - detailList.forEach(detail -> { - detail.setTemplateId(hygieneTemplateEntity.getId()); + for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); // 校验检查项总成绩是否为标准总成绩 BaseUtil.getSumScore(scores, 100); - }); - return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); + } + return hygieneTemplateDetailService.saveBatch(detailList); } /** @@ -70,26 +69,33 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setId(templateId); - hygieneTemplate.setTemplateName(templateName); - boolean updateTemplate = this.updateById(hygieneTemplate); + // 更新模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setId(templateId); + hygieneTemplateEntity.setTemplateName(templateName); + boolean updateTemplate = this.updateById(hygieneTemplateEntity); if (!updateTemplate) { throw new ServiceException("卫生自查模板更新失败"); } + // 更新模板详情 + // 删除旧的模板详情数据 boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId); if (!removeDetail) { throw new ServiceException("卫生自查模板详情数据删除失败"); } + // 新增新的模板详情数据 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); BaseUtil.getSumScore(scores, 100); } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 9434144..26bf967 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -31,9 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', - `CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', - `CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', + `prinicipal` varchar(20) NOT NULL COMMENT '责任人', + `check_item` mediumtext NOT NULL COMMENT '检查项', + `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', From ced0ef786787bbcaa52ff6efc03e644ae9ccdff4 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 28 May 2024 15:07:29 +0800 Subject: [PATCH 101/151] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=BA=BF?= =?UTF-8?q?=E4=B8=8B=E6=93=8D=E4=BD=9C=E7=A5=A8=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/constant/TicketProcessConstant.java | 4 ++ .../entity/StandardTicketInfoEntity.java | 10 +++ .../OfflineOperationTicketProcessServiceImpl.java | 72 ++++++++++++++++++++++ .../hzims-middle/src/main/resources/db/3.0.0.sql | 1 + .../controller/OperationTicketController.java | 17 ++++- .../service/OperationTicketService.java | 3 +- .../service/impl/OperationTicketServiceImpl.java | 11 +++- .../vo/operation/StandardTicketInfoVo.java | 12 ++++ .../ticket/src/main/resources/db/2.0.3.sql | 6 ++ 9 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java create mode 100644 hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql create mode 100644 hzims-service/ticket/src/main/resources/db/2.0.3.sql diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java index d0b79d3..b7ce6c8 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java +++ b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java @@ -74,4 +74,8 @@ public class TicketProcessConstant { * 风险排查标识 */ public static final String HAZARD_RISK = "hazard_risk"; + /** + * 线下操作票标识 + */ + public static final String OFFLINE_OPERATION_TICKET = "OperationTicketOffline"; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java index ade487d..3e49fef 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java @@ -162,4 +162,14 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab @TableField(exist = false) @ApiModelProperty("监护人确认结果:approved-确认,rejected-作废") private String verifyResult; + + @ApiModelProperty("是否线下 : 1-线下,0-线上") + @QueryField(condition = SqlCondition.EQUAL) + private Boolean isOffline; + + @ApiModelProperty("是否审核通过,0为通过,1为未通过") + private Boolean isApproved; + + @ApiModelProperty("图片附件") + private String picture; } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java new file mode 100644 index 0000000..f0a346e --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.middle.processflow.strategy.serviceimpl; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.middle.processflow.service.ProcessDictService; +import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.ticket.ticketprocess.feign.OperationTicketFeignClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OFFLINE_OPERATION_TICKET; + + +/** + * 操作票流程实现类 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/3/28 8:47 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class OfflineOperationTicketProcessServiceImpl extends ProcessAbstractService { + + + + private final OperationTicketFeignClient operationTicketFeignClient; + + + + private final ProcessDictService processDictService; + + + + /** + * 设置执行那种实现类 + * + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + log.info("是否执行操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue); + String dictValue = processDictService.selectDictValueByKey(OFFLINE_OPERATION_TICKET); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行操作票流程环节操作~~~~"); + return true; + } + log.error("未执行操作票流程环节操作,请联系管理员~~~~"); + return false; + } + + /** + * 两票管理业务方法 + * + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + log.info("操作票流程消费调用fein接口开始---param",response); + Boolean pending = operationTicketFeignClient.findPending(response); + if (!pending) { + log.info("操作票流程调用fein接口异常---param",response); + throw new ServiceException("操作票流程出现异常呢"); + } + log.info("操作票流程消费调用fein接口结束---param",response); + } +} diff --git a/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql b/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql new file mode 100644 index 0000000..c1ebcf4 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql @@ -0,0 +1 @@ +INSERT INTO `process_dict`(`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (15, 15, 'OperationTicketOffline', 'OperationTicketOffline', '线下操作票', '线下操作票', 'Y', 0, NULL, '2023-07-25 18:35:01', '2024-05-24 11:22:14', '线下操作票流程'); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java index 56cc07f..3c79c22 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java @@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OFFLINE_OPERATION_TICKET; +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OPERATION_TICKET_KEY; + /** * 操作票 * @Author WL @@ -45,7 +48,19 @@ public class OperationTicketController { @ApiOperation("启动流程") @PostMapping("/startUp") public R start(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) { - operationTicketService.startUp(StandardTicketInfoVo); + operationTicketService.startUp(StandardTicketInfoVo,OPERATION_TICKET_KEY); + return R.success("申请开票成功"); + } + + /** + * 启动流程 + * + * @return + */ + @ApiOperation("启动线下流程") + @PostMapping("/startOffineOperation") + public R startOffineOperation(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) { + operationTicketService.startUp(StandardTicketInfoVo,OFFLINE_OPERATION_TICKET); return R.success("申请开票成功"); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java index 925f8c5..b45f40f 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java @@ -19,7 +19,7 @@ public interface OperationTicketService { * 启动流程 * @param standardTicketInfoVo */ - void startUp(StandardTicketInfoVo standardTicketInfoVo); + void startUp(StandardTicketInfoVo standardTicketInfoVo,String dictValueKey); /** @@ -39,5 +39,4 @@ public interface OperationTicketService { - } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java index d0fbf33..5ca66c0 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java @@ -100,7 +100,7 @@ public class OperationTicketServiceImpl implements OperationTicketService { * @param standardTicketInfoVo */ @Override - public void startUp(StandardTicketInfoVo standardTicketInfoVo) { + public void startUp(StandardTicketInfoVo standardTicketInfoVo,String dictValueKey) { log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法"); if (standardTicketInfoVo.getSignage() == null) { throw new ServiceException("票据抬头未配置,请您到站点管理配置"); @@ -134,6 +134,7 @@ public class OperationTicketServiceImpl implements OperationTicketService { String code = processDictFeignService.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType())); log.info("获取编码: {}", code); if (StringUtils.isBlank(code)) { + log.error("获取操作票编码异常:"+code); throw new ServiceException("服务器异常,请联系管理员"); } standardTicketInfoVo.setCode(code); @@ -143,9 +144,10 @@ public class OperationTicketServiceImpl implements OperationTicketService { List standardTicketInfoVos = this.saveStandardTicketMeasure(this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo)); standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); //6. 查询第操作票值 - String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY); + String dictValue = processDictFeignService.selectDictValueByKey(dictValueKey); log.info("查询第操作票值: {}", dictValue); if (StringUtils.isBlank(dictValue)) { + log.error("查询不到操作票值"); throw new ServiceException("服务器异常,请联系管理员"); } // 7.启动流程 @@ -337,7 +339,9 @@ public class OperationTicketServiceImpl implements OperationTicketService { Map params = new HashMap<>(4); params.put("standardTicketInfoVo", standardTicketInfoVo); params.put("taskId", standardTicketInfoVo.getId()); - params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); + if(ObjectUtil.isNotEmpty(standardTicketInfoVo.getGuardian())){ + params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); + } //已开启流程 R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params); if (!processInstanceContainNameByKey.isSuccess()) { @@ -434,6 +438,7 @@ public class OperationTicketServiceImpl implements OperationTicketService { boolean save = standardTicketInfoService.save(standardTicketInfo); if (!save) { + log.error("saveStandardTicketInfo failed"); throw new ServiceException("Save failed"); } BeanUtils.copyProperties(standardTicketInfo, standardTicketInfoVo); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java index e777e6e..cf8e741 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tenant.mp.TenantEntity; import org.springframework.format.annotation.DateTimeFormat; @@ -152,4 +154,14 @@ public class StandardTicketInfoVo extends TenantEntity { @ApiModelProperty("安全措施") private List standardTicketMeasureVos; + + @ApiModelProperty("是否线下 : 1-线下,0-线上") + @QueryField(condition = SqlCondition.EQUAL) + private Boolean isOffline; + + @ApiModelProperty("是否审核通过 : 1-通过,0-未通过") + private Boolean isApproved; + + @ApiModelProperty("图片附件") + private String picture; } diff --git a/hzims-service/ticket/src/main/resources/db/2.0.3.sql b/hzims-service/ticket/src/main/resources/db/2.0.3.sql new file mode 100644 index 0000000..755f8ce --- /dev/null +++ b/hzims-service/ticket/src/main/resources/db/2.0.3.sql @@ -0,0 +1,6 @@ +alter table `hzims_standard_ticket_info` add column `is_offline` tinyint(2) default 0 comment '是否线下 : 1-线下,0-线上'; +alter table `hzims_standard_ticket_info` add column `is_approved` tinyint(2) default NULL comment '是否审核通过 : 1-通过,0-未通过'; +alter table `hzims_standard_ticket_info` ADD COLUMN `picture` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片附件' ; +ALTER TABLE `hzims_standard_ticket_info` + MODIFY COLUMN `issue_order_person` bigint(20) NULL COMMENT '发令人' AFTER `code`, + MODIFY COLUMN `access_order_person` bigint(20) NULL COMMENT '受令人' AFTER `issue_order_person`; \ No newline at end of file From b3cbe8b30a68c6b06551a29fa750e70c1a1a157a Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 28 May 2024 16:07:29 +0800 Subject: [PATCH 102/151] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/entity/HygieneTemplateEntity.java | 4 +++ .../safeproduct/controller/HygieneController.java | 4 +-- .../safeproduct/mapper/HygieneTemplateMapper.java | 10 +++++++ .../safeproduct/mapper/HygieneTemplateMapper.xml | 13 +++++++++ .../safeproduct/service/IHygieneRecordService.java | 8 ++++++ .../service/IHygieneTemplateService.java | 12 +++++++++ .../service/impl/HygienePlanServiceImpl.java | 29 +++++++++++++++++--- .../service/impl/HygieneRecordServiceImpl.java | 10 +++++++ .../service/impl/HygieneTemplateServiceImpl.java | 31 ++++++++++++++++++++++ 9 files changed, 115 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java index 9a82c8f..9875675 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzims.safeproduct.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -18,4 +19,7 @@ public class HygieneTemplateEntity extends BaseEntity { @ApiModelProperty("模板名称") private String templateName; + + @TableField(exist = false) + private String createDeptName; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index fe2739c..8290da9 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; @@ -228,8 +227,7 @@ public class HygieneController extends BladeController { @ApiOperationSupport(order = 19) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) public R> hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( - param, HygieneTemplateEntity.class)); + IPage page = hygieneTemplateService.getHygieneTemplatePage(param, query); return R.data(page); } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java index 1a76e7c..d5bcf94 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java @@ -1,9 +1,12 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.Map; + /** * 卫生自查模板Mapper类 * @@ -12,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface HygieneTemplateMapper extends BaseMapper { + /** + * 卫生自查页面 + * @param param 参数 + * @param page 分页类 + * @return 页面 + */ + IPage getHygieneTemplatePage(IPage page, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml index 28b08b9..cdb1378 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml @@ -1,4 +1,17 @@ + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java index 86d8637..7d050d0 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java @@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; /** @@ -62,4 +63,11 @@ public interface IHygieneRecordService extends IService { * @param response 响应类 */ void exportHygieneRecordData(Long id, HttpServletResponse response); + + /** + * 查询关联卫生自查记录 + * @param planId 计划id + * @return 记录列表 + */ + List getReferenceRecord(Long planId); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java index 5f45e16..bd908d6 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java @@ -1,9 +1,13 @@ package com.hnac.hzims.safeproduct.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; +import org.springblade.core.mp.support.Query; + +import java.util.Map; /** * 卫生自查模板服务类 @@ -46,4 +50,12 @@ public interface IHygieneTemplateService extends IService * @return 模板实体类 */ HygieneTemplateEntity getHygieneTemplateByName(String name); + + /** + * 卫生自查页面 + * @param param 参数 + * @param query 分页类 + * @return 页面 + */ + IPage getHygieneTemplatePage(Map param, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index 4ad0ca5..d0d3b88 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -7,11 +7,13 @@ import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; +import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; @@ -39,6 +41,7 @@ import java.net.URLEncoder; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /** * 卫生自查计划服务实现类 @@ -139,9 +142,10 @@ public class HygienePlanServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().ne(HygienePlanEntity::getId, hygienePlanDTO.getId()); + queryWrapper.lambda().ne(HygienePlanEntity::getId, planId); queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName()); HygienePlanEntity hygienePlan = this.getOne(queryWrapper); if (hygienePlan != null) { @@ -157,7 +161,7 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); // 删除旧的责任区数据 - boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); + boolean removeZone = hygieneZoneService.removeReferenceZone(planId); if (!removeZone) { throw new ServiceException("删除旧的责任区数据失败"); } @@ -170,7 +174,26 @@ public class HygienePlanServiceImpl extends ServiceImpl recordList = hygieneRecordService.getReferenceRecord(planId); + if (CollectionUtils.isNotEmpty(recordList)) { + List zones = hygieneZoneService.getReferenceZone(planId); + List ids = zones.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList()); + StringBuilder zoneIds = new StringBuilder(); + for (int i = 0; i < ids.size(); i++) { + zoneIds.append(ids.get(i)); + if (i != ids.size() - 1) { + zoneIds.append(","); + } + } + recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString())); + return R.status(hygieneRecordService.updateBatchById(recordList)); + } + return R.status(Boolean.TRUE); } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index b38db24..5392c0a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -200,6 +200,16 @@ public class HygieneRecordServiceImpl extends ServiceImpl getReferenceRecord(Long planId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneRecordEntity::getHygienePlanId, planId); + return this.list(queryWrapper); + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java index af8ff3a..f2f99b5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java @@ -1,6 +1,8 @@ package com.hnac.hzims.safeproduct.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; @@ -11,12 +13,17 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.system.feign.ISysClient; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -30,6 +37,12 @@ public class HygieneTemplateServiceImpl extends ServiceImpl getHygieneTemplatePage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + IPage templatePage = hygieneTemplateMapper.getHygieneTemplatePage(page, param); + List templateList = templatePage.getRecords(); + templateList.forEach(template -> { + R deptName = sysClient.getDeptName(template.getCreateDept()); + if (deptName.isSuccess()) { + template.setCreateDeptName(deptName.getData()); + } + }); + templatePage.setRecords(templateList); + return templatePage; + } } From 52ffb6052a0ee0cb30be808fccbb60e1be5b2f0e Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 28 May 2024 18:42:05 +0800 Subject: [PATCH 103/151] =?UTF-8?q?add:=20=E8=BD=A6=E6=A3=80=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/entity/CarCheckTemplateEntity.java | 14 +++++ .../safeproduct/controller/CarController.java | 10 ++-- .../safeproduct/mapper/CarCheckTemplateMapper.java | 10 ++++ .../safeproduct/mapper/CarCheckTemplateMapper.xml | 5 ++ .../service/ICarCheckTemplateService.java | 14 +++++ .../service/impl/CarCheckRecordServiceImpl.java | 64 ++++++++++++++-------- .../service/impl/CarCheckTemplateServiceImpl.java | 21 +++++++ 7 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java new file mode 100644 index 0000000..95eaf33 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.safeproduct.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * @date 2024-05-28 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CarCheckTemplateEntity extends BaseEntity { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java index 2f1c8c8..781b214 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java @@ -54,6 +54,8 @@ public class CarController extends BladeController { private final ICarInsuranceService carInsuranceService; + private final ICarCheckTemplateService carCheckTemplateService; + @PostMapping("/saveCar") @ApiOperation(value = "新增车辆") @ApiOperationSupport(order = 1) @@ -272,17 +274,17 @@ public class CarController extends BladeController { // @ApiOperation(value = "新增车检记录模板") // @ApiOperationSupport(order = 39) // public R saveCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.saveCarCheckTemplate()); // } -// + // @ApiOperationSupport(order = 40) // public R updateCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.updateCarCheckTemplate()); // } // // @ApiOperationSupport(order = 41) // public R removeCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.removeCarCheckTemplate()); // } // // @ApiOperationSupport(order = 42) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java new file mode 100644 index 0000000..d813c0c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CarCheckTemplateMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml new file mode 100644 index 0000000..7b5b718 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java new file mode 100644 index 0000000..7fcc1da --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; + +/** + * 车检模板服务类 + * + * @date 2024-05-28 + */ +public interface ICarCheckTemplateService extends IService { + + boolean saveCarCheckTemplate(); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java index 864dd53..a9b131d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java @@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO; import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.utils.BeanUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -70,13 +71,13 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); - itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); - return carCheckItemService.saveBatch(itemList); + if (!saveRecord) { + throw new ServiceException("车检记录新增失败"); } - return false; + CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code); + List itemList = carCheckRecordDTO.getItemList(); + itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); + return carCheckItemService.saveBatch(itemList); } /** @@ -104,7 +105,19 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckItemService.getListByCarCheckRecordId(id); - carCheckRecordDetailVO.setCheckItemList(itemList); + List checkItemList = new ArrayList<>(); + itemList.forEach(item -> { + String[] contents = item.getCheckContent().split(",|,"); + String[] results = item.getCheckResult().split(",|,"); + for (int i = 0; i < contents.length; i++) { + CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity(); + carCheckItemEntity.setCheckItem(item.getCheckItem()); + carCheckItemEntity.setCheckContent(contents[i]); + carCheckItemEntity.setCheckResult(results[i]); + checkItemList.add(carCheckItemEntity); + } + }); + carCheckRecordDetailVO.setCheckItemList(checkItemList); return carCheckRecordDetailVO; } return null; @@ -157,22 +170,25 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); - itemList.forEach(x -> {x.setCarCheckRecordId(carCheckRecordDTO.getId()); - x.setId(null);}); - boolean b = carCheckItemService.saveBatch(itemList); - if (b) { - // 若更新检查项成功,则更新车检记录 - CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity(); - BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity); - return this.updateById(carCheckRecordEntity); + // 删除旧的检查项 + boolean deleteItem = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId()); + if (!deleteItem) { + throw new ServiceException("旧的车检记录检查项删除失败"); } - return false; + // 新增新的检查项 + List itemList = carCheckRecordDTO.getItemList(); + itemList.forEach(x -> { + x.setCarCheckRecordId(carCheckRecordDTO.getId()); +// x.setId(null); + }); + return carCheckItemService.saveBatch(itemList); } /** @@ -182,10 +198,10 @@ public class CarCheckRecordServiceImpl extends ServiceImpl implements ICarCheckTemplateService { + + @Override + public boolean saveCarCheckTemplate() { + return false; + } +} From 03ecbafe4441663c063d336da36034097e487be4 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 28 May 2024 19:44:42 +0800 Subject: [PATCH 104/151] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=A8=A1=E6=9D=BF=E8=AF=A6=E6=83=85=E8=A1=A8=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/safeproduct/src/main/resources/db/2.0.1.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 26bf967..516bede 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `prinicipal` varchar(20) NOT NULL COMMENT '责任人', + `principal` varchar(20) NOT NULL COMMENT '责任人', `check_item` mediumtext NOT NULL COMMENT '检查项', `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', From 0060d8446c409396d03e86388529f81ffd190048 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 29 May 2024 16:15:15 +0800 Subject: [PATCH 105/151] =?UTF-8?q?add:=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 3 +- .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 9 +- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 1 + .../interactive/constants/DataMethodEnum.java | 36 ++++++ .../bigmodel/interactive/constants/DateEnum.java | 40 ++++++ .../interactive/constants/FuncRouteEnum.java | 3 +- .../controller/AnalyseDataController.java | 34 ++++++ .../interactive/service/IAnalyseDataService.java | 16 +++ .../service/impl/AnalyseDataServiceImpl.java | 136 +++++++++++++++++++++ .../service/impl/ExtraResolveStrategyService.java | 42 ++++--- .../service/impl/InteractiveServiceImpl.java | 13 +- .../interactive/vo/HistoryDataSearchVO.java | 35 ++++++ .../inspect/obj/mapper/ProjectContentMapper.xml | 2 +- 13 files changed, 332 insertions(+), 38 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 6a2d62d..4005c37 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -23,7 +23,8 @@ public interface FunctionConstants { /**选项**/ CHOOSE("4"), /**确认**/ - CONFIRM("5") + CONFIRM("5"), + CHART("6"); ; @Getter private String type; diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java index 1f2fcfd..b23874f 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -21,12 +21,15 @@ public class DataVO implements Serializable { @JSONField(name = "time_end") private String endTime; - /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ - private String method; - /**实时数据结果集**/ private RealDataVO real; private DataItemVO item; + /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ + private String method; + + @JSONField(name = "data_type") + private String dataType; + } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 951bf42..0563a74 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -39,4 +39,5 @@ public class ExtraVO implements Serializable { @ApiModelProperty("选项") private List selection; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java new file mode 100644 index 0000000..49a117b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataMethodEnum.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/29 08:31 + */ +@AllArgsConstructor +public enum DataMethodEnum { + USUAL("详情",6,"详情"), + EARLIEST("最早值",0,"最早值"), + MAX("最大值",1,"最大值"), + MIN("最小值",2,"最小值"), + AVERAGE("平均值",3,"平均值"), + SUM("累计值/和值",4,"总和值"), + DIFFERENCE("变化值/差值",5,"变化值"), + LATEST("最新值",6,"最新值"), + ; + @Getter + private String name; + @Getter + private Integer accessRule; + @Getter + private String method; + + public static DataMethodEnum getEnumByMethod(String method) { + return Arrays.stream(DataMethodEnum.class.getEnumConstants()) + .filter(e -> e.getMethod().equals(method)) + .findFirst().orElse(null); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java new file mode 100644 index 0000000..82f5cba --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:37 + */ +@AllArgsConstructor +public enum DateEnum { + YEAR("year","年","按年",5,6), + MONTH("month","月","按月",4,5), + DAY("day","日","按日",3,3), + HOUR("hour","时","按时",2,2), + MINUTE("minute","分","按分",1,1), + SECOND("second","秒","按秒",0,0), + ; + @Getter + private String code; + @Getter + private String name; + @Getter + private String dateType; + @Getter + private int order; + @Getter + private Integer saveTimeType; + + public static DateEnum getDateEnumByType(String dateType) { + return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getDateType().equals(dateType)).findFirst().orElse(null); + } + + public static DateEnum getDateEnumByOrder(int order) { + return Arrays.stream(DateEnum.class.getEnumConstants()).filter(d -> d.getOrder() == order).findFirst().orElse(null); + } + +} 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 8ce75d0..99275b9 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 @@ -21,7 +21,8 @@ public enum FuncRouteEnum { CHOOSE_FAULT("choose_fault","选择故障",null), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), - CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE) + CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), + HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java new file mode 100644 index 0000000..63c6750 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.bigmodel.interactive.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; +import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: huangxing + * @Date: 2024/05/29 09:22 + */ +@RequestMapping("/analyse/data") +@AllArgsConstructor +@Api(value = "数据查询管理",tags = "数据查询管理") +@RestController +public class AnalyseDataController { + + private final IAnalyseDataService analyseDataService; + + @GetMapping("/getHistoryData") + @ApiOperation("获取历史数据") + @ApiOperationSupport(order = 1) + public R getHistoryData(@Validated HistoryDataSearchVO searchVO) { + return R.data(analyseDataService.getHistoryData(searchVO)); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java new file mode 100644 index 0000000..d290dab --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnalyseDataService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:29 + */ +public interface IAnalyseDataService { + + ExtraVO getHistoryData(HistoryDataSearchVO searchVO); + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java new file mode 100644 index 0000000..9cfc479 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -0,0 +1,136 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; +import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.Period; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:29 + */ +@Service +@AllArgsConstructor +public class AnalyseDataServiceImpl implements IAnalyseDataService { + + private final DeviceDataClient deviceDataClient; + public static final int DATA_COUNT_MAX = 8000; + + @Override + public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { + if(DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { + searchVO.setDataType(DateEnum.SECOND.getDateType()); + } + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + searchVO.setDataType(dateEnum.getDateType()); + // 获取最适配时间段 + DateEnum adapterDate = this.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); + searchVO.setDataType(adapterDate.getDateType()); + String label = "根据数据量匹配到的取数规则为:" + adapterDate.getDateType() + "查询,查询结果如下:"; + ExtraVO extraVO = new ExtraVO(); + extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); + extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); + extraVO.setLabel(label); + Map params = new HashMap<>(1); + ReductionDataVO dataVO = this.getPolymerizationData(searchVO); + List datalist = dataVO.getDataList().stream().map(m -> { + m.put("val", m.get(searchVO.getSignage())); + m.remove(searchVO.getSignage()); + return m; + }).collect(Collectors.toList()); + params.put("data",datalist); + params.put("deviceName",searchVO.getDeviceName()); + params.put("attrName",dataVO.getFieldMap().get(searchVO.getSignage())); + params.put("stationName",searchVO.getStationName()); + extraVO.setParams(params); + return extraVO; + } + + private ReductionDataVO getPolymerizationData(HistoryDataSearchVO searchVO) { + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { + throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); + }); + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + ReductionDataDTO dataDTO = new ReductionDataDTO(); + ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); + reductionAttrData.setSignage(searchVO.getSignage()); + reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); + reductionAttrData.setKeepFigures(2); + dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(),DateUtil.DATETIME_FORMATTER)); + dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); + dataDTO.setDeviceCode(searchVO.getDeviceCode()); + dataDTO.setNeedPage(false); + dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); + dataDTO.setTimeInterval(1); + dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); + Result dataVO = deviceDataClient.pageDeviceCodeAndSignages(dataDTO); + Assert.isTrue(dataVO.isSuccess(),() -> { + throw new ServiceException("聚合历史数据查询失败!"); + }); + return dataVO.getData(); + } + + private DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { + LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); + LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); + Duration duration = Duration.between(start, end); + int count; + switch(dateEnum) { + case YEAR: + count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case MONTH: + count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case DAY: + count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case HOUR: + count = Long.valueOf(duration.toHours()).intValue(); + break; + case MINUTE: + count = Long.valueOf(duration.toMinutes()).intValue(); + break; + case SECOND: + count = Long.valueOf(duration.getSeconds()).intValue(); + break; + default: + throw new ServiceException("未找到相关时间类型,查询失败!"); + } + if(count <= DATA_COUNT_MAX) { + return dateEnum; + } + else { + return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); + } + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 60d910d..8c5999e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; +import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; import com.hnac.hzims.bigmodel.interactive.vo.*; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -44,8 +46,7 @@ public class ExtraResolveStrategyService { private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; private final DeviceClient deviceClient; - private final BladeLogger logger; - private final RedisTemplate redisTemplate; + private final IAnalyseDataService analyseDataService; /** * 解析DFP返回extra @@ -101,10 +102,6 @@ public class ExtraResolveStrategyService { } private ExtraVO resolveShowParam(Map extra) { - ExtraVO result = new ExtraVO(); - result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); - result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); - Map param = new HashMap(1); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); if(Func.isNotEmpty(data)) { if(Func.isNotEmpty(data.getReal())) { @@ -114,21 +111,26 @@ public class ExtraResolveStrategyService { real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); } } -// if(Func.isNotEmpty(data.getItem())) { -// if("历史".equals(data.getType())) { -// // 历史数据需要手动查询功能ID供前端使用 -// DataItemVO item = data.getItem(); -// R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); -// if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { -// List attrList = attrR.getData(); -// Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) -// .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); -// logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); -// item.setAttrId(facDeviceIdOptional.orElse(null)); -// } -// } -// } + if(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod())) { + if(SearchTypeEnum.HISTORY.getSearchType().equals(data.getType()) && Func.isNotEmpty(data.getItem())) { + DataItemVO item = data.getItem(); + HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); + searchVO.setDataType(data.getDataType()); + searchVO.setDeviceCode(item.getDeviceId()); + searchVO.setDeviceName(item.getDeviceName()); + searchVO.setStationName(item.getProjectName()); + searchVO.setMethod(data.getMethod()); + searchVO.setSignage(item.getSignage()); + searchVO.setStartTime(data.getStartTime()); + searchVO.setEndTime(data.getEndTime()); + return analyseDataService.getHistoryData(searchVO); + } + } } + ExtraVO result = new ExtraVO(); + result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); + result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); + Map param = new HashMap(1); param.put("data", data); result.setParams(param); return result; 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 8041056..317f17d 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 @@ -275,18 +275,7 @@ public class InteractiveServiceImpl implements IInteractiveService { throw new ServiceException("远程调用大模型【删除对话】接口失败!"); } // 移除对应reids中问题标记 - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)) { - return true; - } - List sessionIds = JSONObject.parseArray(json.toString(),String.class); - if(CollectionUtil.isEmpty(sessionIds)){ - return true; - } - if(sessionIds.contains(sessionId)){ - sessionIds.remove(sessionId); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(sessionIds)); - } + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); return true; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java new file mode 100644 index 0000000..b6ea2f9 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Author: huangxing + * @Date: 2024/05/28 11:48 + */ +@Data +public class HistoryDataSearchVO { + + @NotBlank + private String startTime; + + @NotBlank + private String endTime; + + @NotBlank + private String deviceCode; + + @NotBlank + private String signage; + + @NotBlank + private String method; + + private String dataType; + + private String stationName; + + private String deviceName; + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml index 2c8cb02..9f9d5d5 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml @@ -3,7 +3,7 @@ + SELECT + * + FROM + car_check_template_detail + WHERE + is_deleted = 0 + + AND template_name like concate('%', #{param.templateName}, '%') + + ORDER BY + create_time DESC + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java index 7fcc1da..58dc07e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java @@ -1,7 +1,13 @@ package com.hnac.hzims.safeproduct.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO; import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; +import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO; +import org.springblade.core.mp.support.Query; + +import java.util.Map; /** * 车检模板服务类 @@ -10,5 +16,46 @@ import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; */ public interface ICarCheckTemplateService extends IService { - boolean saveCarCheckTemplate(); + /** + * 新增车检模板 + * @param dto 车检模板dto类 + * @return true-成功,false-失败 + */ + boolean saveCarCheckTemplate(CarCheckTemplateDTO dto); + + /** + * 根据名称获取车检模板 + * @param name 模板名称 + * @return 车检模板实体类 + */ + CarCheckTemplateEntity getCarCheckTemplateByName(String name); + + /** + * 修改车检模板 + * @param dto 车检模板dto类 + * @return true-成功,false-失败 + */ + boolean updateCarCheckTemplate(CarCheckTemplateDTO dto); + + /** + * 删除车检模板 + * @param id 模板id + * @return true-成功,false-失败 + */ + boolean removeCarCheckTemplate(Long id); + + /** + * 车检模板详情 + * @param id 模板id + * @return 模板详情VO类 + */ + CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id); + + /** + * 车检分页 + * @param query 分页类 + * @param param 参数 + * @return 分页 + */ + IPage getCarCheckTemplatePage(Query query, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java index a9b131d..69ae394 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java @@ -69,11 +69,12 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateDetailServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateDetailServiceImpl.java new file mode 100644 index 0000000..0feefd1 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateDetailServiceImpl.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; +import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateDetailMapper; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 车检模板详情服务实现类 + * + * @date 2024-05-30 + */ +@Service +public class CarCheckTemplateDetailServiceImpl extends ServiceImpl + implements ICarCheckTemplateDetailService { + + /** + * 删除关联的模板详情数据 + */ + @Override + public boolean removeReferenceDetail(Long templateId) { + List list = this.getReferenceDetail(templateId); + List ids = list.stream().map(CarCheckTemplateDetailEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + @Override + public List getReferenceDetail(Long templateId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(CarCheckTemplateDetailEntity::getTemplateId, templateId); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java index eb314be..fe2c069 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java @@ -1,10 +1,25 @@ package com.hnac.hzims.safeproduct.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; +import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO; +import com.hnac.hzims.safeproduct.entity.*; import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper; import com.hnac.hzims.safeproduct.service.ICarCheckTemplateService; +import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.system.feign.ISysClient; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; /** * 车检模板服务实现类 @@ -14,8 +29,133 @@ import org.springframework.stereotype.Service; @Service public class CarCheckTemplateServiceImpl extends ServiceImpl implements ICarCheckTemplateService { + @Autowired + ICarCheckTemplateDetailService carCheckTemplateDetailService; + + @Resource + CarCheckTemplateMapper carCheckTemplateMapper; + + @Autowired + ISysClient sysClient; + + /** + * 新增车检模板 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveCarCheckTemplate(CarCheckTemplateDTO dto) { + String templateName = dto.getTemplateName(); + // 重名校验 + CarCheckTemplateEntity template = getCarCheckTemplateByName(templateName); + if (template != null) { + throw new ServiceException("模板名不可重复"); + } + // 新增车检模板 + CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity(); + templateEntity.setTemplateName(templateName); + boolean saveTemplate = this.save(templateEntity); + if (!saveTemplate) { + throw new ServiceException("车检模板新增失败"); + } + // 新增模板详情 + template = getCarCheckTemplateByName(templateName); + List details = dto.getDetailList(); + for (CarCheckTemplateDetailEntity detail : details) { + detail.setTemplateId(template.getId()); + } + return carCheckTemplateDetailService.saveBatch(details); + } + + /** + * 根据名称获取车检模板 + */ + public CarCheckTemplateEntity getCarCheckTemplateByName(String name) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, name); + return this.getOne(queryWrapper); + } + + /** + * 修改车检模板 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateCarCheckTemplate(CarCheckTemplateDTO dto) { + String templateName = dto.getTemplateName(); + Long templateId = dto.getId(); + // 重名校验 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, templateName); + queryWrapper.lambda().ne(CarCheckTemplateEntity::getId, templateId); + CarCheckTemplateEntity template = this.getOne(queryWrapper); + if (template != null) { + throw new ServiceException("模板名不可重复"); + } + // 更新模板 + CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity(); + templateEntity.setId(templateId); + templateEntity.setTemplateName(templateName); + boolean updateTemplate = this.updateById(templateEntity); + if (!updateTemplate) { + throw new ServiceException("车检模板更新失败"); + } + // 更新模板详情 + // 删除旧的模板详情数据 + boolean removeDetail = carCheckTemplateDetailService.removeReferenceDetail(templateId); + if (!removeDetail) { + throw new ServiceException("车检模板详情数据删除失败"); + } + // 新增新的模板详情数据 + List detailList = dto.getDetailList(); + for (CarCheckTemplateDetailEntity detail : detailList) { + detail.setTemplateId(templateId); + } + return carCheckTemplateDetailService.saveBatch(detailList); + } + + /** + * 删除车检模板 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean removeCarCheckTemplate(Long id) { + boolean removeTemplate = this.removeById(id); + if (!removeTemplate) { + throw new ServiceException("车检模板删除失败"); + } + return carCheckTemplateDetailService.removeReferenceDetail(id); + } + + /** + * 车检模板详情 + */ + @Override + public CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id) { + CarCheckTemplateEntity templateEntity = this.getById(id); + CarCheckTemplateDetailVO vo = new CarCheckTemplateDetailVO(); + vo.setId(templateEntity.getId()); + vo.setTemplateName(templateEntity.getTemplateName()); + List list = carCheckTemplateDetailService.getReferenceDetail(id); + vo.setTemplateDetailList(list); + return vo; + } + + /** + * 车检分页 + */ @Override - public boolean saveCarCheckTemplate() { - return false; + public IPage getCarCheckTemplatePage(Query query, Map param) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + IPage templatePage = carCheckTemplateMapper.getCarCheckTemplatePage(page, param); + List templateList = templatePage.getRecords(); + // 获取机构名 + templateList.forEach(template -> { + R deptName = sysClient.getDeptName(template.getCreateDept()); + if (deptName.isSuccess()) { + template.setCreateDeptName(deptName.getData()); + } + }); + templatePage.setRecords(templateList); + return templatePage; } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ICarCheckTemplateDetailService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ICarCheckTemplateDetailService.java new file mode 100644 index 0000000..3a7315a --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ICarCheckTemplateDetailService.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity; + +import java.util.List; + +/** + * 车检模板详情服务类 + * + * @date 2024-05-30 + */ +public interface ICarCheckTemplateDetailService extends IService { + + /** + * 删除关联的模板详情数据 + * @param templateId 模板id + * @return true-成功,false-失败 + */ + boolean removeReferenceDetail(Long templateId); + + /** + * 查询关联的模板详情列表 + * @param templateId 模板id + * @return 模板详情列表 + */ + List getReferenceDetail(Long templateId); +} diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 516bede..733ffca 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -46,4 +46,34 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( -- 添加考试及格分字段 ALTER TABLE hzims_test - ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分'; \ No newline at end of file + ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分'; + +-- 新增车检模板表 +CREATE TABLE IF NOT EXISTS `hzims_hygiene_template` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `template_name` varchar(50) NOT NULL COMMENT '模板名称', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板表'; + +-- 新增车检模板详情表 +CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `template_id` bigint(20) NOT NULL COMMENT '模板id', + `check_item` varchar(500) NOT NULL COMMENT '检查项目', + `check_content` mediumtext NOT NULL COMMENT '检查内容', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板详情表'; \ No newline at end of file From 24bc529965b4d3b08434431137f3a763e072dbd0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 30 May 2024 15:37:17 +0800 Subject: [PATCH 110/151] =?UTF-8?q?add:=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/constants/DateEnum.java | 1 + .../service/impl/AnalyseDataServiceImpl.java | 4 ++-- .../service/impl/InteractiveServiceImpl.java | 14 ++++++++++--- .../bigmodel/schedule/InteractiveSchedule.java | 23 +++++++++++----------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java index 019f2ef..a615988 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java @@ -17,6 +17,7 @@ public enum DateEnum { HOUR("hour","每小时","按小时",2,2), MINUTE("minute","每分钟","按分钟",1,1), SECOND("second","每秒","按秒",0,0), + USUAL("usual","详情","按秒",0,0) ; @Getter private String code; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 2385bca..aac20c6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -73,9 +73,9 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { String label = searchVO.getStationName() + "_" + searchVO.getDeviceName() + "_" + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" - + adapterDate.getName() + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) + enumByMethod.getMethod() - + note + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) + ":"; extraVO.setLabel(label); params.put("data",datalist); 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 1531362..ba92539 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 @@ -109,7 +109,7 @@ public class InteractiveServiceImpl implements IInteractiveService { extraVO.setFuncCode("stations_num"); String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(!startTime.equals(endTime)) { + if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) { label = String.format("自%s到%s时间为止,",startTime,endTime); } else { @@ -239,12 +239,20 @@ public class InteractiveServiceImpl implements IInteractiveService { logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); } result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); Object[] extras = answerVO.getExtras(); if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){ return; } - List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); - answerVO.setExtras(extraList.toArray(new String[extraList.size()])); + try { + List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); + answerVO.setExtras(extraList.toArray(new String[extraList.size()])); + } + catch(Exception e) { + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,answerVO.getSessionId()); + e.printStackTrace(); + throw new RuntimeException(e); + } }); 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 e145733..6d02c9c 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 @@ -97,19 +97,18 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); - answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { - XxlJobLogger.log("开始获取" + answerVO.getSessionId() + "答案!"); - if(sessionIds.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - if(Func.isNotEmpty(session)) { - wsService.sendMessage(session,message); + for (AnswerVO answerVO : answerList) { + Runnable task = () -> { + if(sessionIds.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } } - } - if(answerVO.getRunning() == 0) { - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); - } - }, getAnswerPoolExecutor)); + }; + getAnswerPoolExecutor.submit(task); + } return ReturnT.SUCCESS; } From 0c70821df34426e6a6bea57ef6517f5679e68f35 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 30 May 2024 19:10:16 +0800 Subject: [PATCH 111/151] =?UTF-8?q?add:=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 18 +-------- .../bigmodel/schedule/InteractiveSchedule.java | 43 ++++++++++++++-------- .../websocket/handler/InteractiveHandler.java | 14 ++----- pom.xml | 2 +- 4 files changed, 35 insertions(+), 42 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 ba92539..2fd2480 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 @@ -238,25 +238,11 @@ public class InteractiveServiceImpl implements IInteractiveService { if(CollectionUtil.isNotEmpty(result)) { logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); } - result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); - Object[] extras = answerVO.getExtras(); - if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){ - return; - } - try { - List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); - answerVO.setExtras(extraList.toArray(new String[extraList.size()])); - } - catch(Exception e) { - redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,answerVO.getSessionId()); - e.printStackTrace(); - throw new RuntimeException(e); - } - }); return result; } + + @Override public Boolean authentication(String stationId, String userId, String func,String sessionId) { // 站点鉴权 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 6d02c9c..759c3b8 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 @@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.schedule; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.interactive.service.impl.ExtraResolveStrategyService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; @@ -32,10 +33,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; @@ -66,6 +64,8 @@ public class InteractiveSchedule { private final IStationClient stationClient; + private final ExtraResolveStrategyService extraResolveStrategyService; + // @XxlJob(GET_INTERACTIVE_RESULT) // public ReturnT execute(String params) { // String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); @@ -97,18 +97,31 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); - for (AnswerVO answerVO : answerList) { - Runnable task = () -> { - if(sessionIds.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - if(Func.isNotEmpty(session)) { - wsService.sendMessage(session,message); - } + answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> { + // 如果已经获取到答案 则删除缓存 + if(answerVO.getRunning() == 0) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); + } + Object[] extras = answerVO.getExtras(); + if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){ + try { + List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); + answerVO.setExtras(extraList.toArray(new String[extraList.size()])); } - }; - getAnswerPoolExecutor.submit(task); - } + catch(Exception e) { + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,answerVO.getSessionId()); + e.printStackTrace(); + throw new RuntimeException(e); + } + } + if(sessionIds.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } + } + }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } 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 c8a5ce8..e956400 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 @@ -106,6 +106,8 @@ public class InteractiveHandler extends TextWebSocketHandler { FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); switch (funcEnum) { case CHOOSE_STATION: + case CHOOSE_YC: + case CHOOSE_FAULT: this.handleDefaultChoose(messageContext,sessionId); break; case CHOOSE_VIDEO: @@ -114,11 +116,6 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_CANVAS: this.handleScadaChoose(messageContext,sessionId); break; - case CHOOSE_FAULT: - this.handleFaultChoose(messageContext,sessionId); - break; - case CHOOSE_YC: - this.handleDataChoose(messageContext,sessionId); default: break; } @@ -135,7 +132,7 @@ public class InteractiveHandler extends TextWebSocketHandler { data.put("station_name",selectionVO.getName()); Map extra = new HashMap<>(2); extra.put("func",funcCode); - extra.put("data",data); + extra.put("data",messageContext.getObject("selection", JSONObject.class)); interactiveService.specialAsk(sessionId,userId,extra); } @@ -203,12 +200,9 @@ public class InteractiveHandler extends TextWebSocketHandler { String userId = messageContext.getString("userId"); String funcCode = messageContext.getString("funcCode"); FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); - JSONObject data = new JSONObject(); - data.put("id",selectionVO.getId()); - data.put("name",selectionVO.getName()); Map extra = new HashMap<>(2); extra.put("func",funcCode); - extra.put("data",data); + extra.put("data",selectionVO); interactiveService.specialAsk(sessionId,userId,extra); } diff --git a/pom.xml b/pom.xml index 226f1e4..7672dcf 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ org.springblade blade-system-api - ${bladex.project.version} + 5.1.1.RELEASE.fix.4 org.springblade From 305b8098b1450cdd766350ca32eeadfd85e4ebd5 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 31 May 2024 13:45:28 +0800 Subject: [PATCH 112/151] =?UTF-8?q?fix=EF=BC=9Achoose=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 2 +- .../bigmodel/interactive/vo/FaultSelectionVO.java | 2 + .../bigmodel/interactive/vo/RemoteSelectionVO.java | 13 +++ .../bigmodel/interactive/vo/ScadaSelectionVO.java | 2 + .../interactive/constants/FuncRouteEnum.java | 15 +-- .../service/impl/ExtraResolveStrategyService.java | 109 +++++++++++---------- .../websocket/handler/InteractiveHandler.java | 27 +---- pom.xml | 2 +- 8 files changed, 87 insertions(+), 85 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 0563a74..9b2ab5f 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -38,6 +38,6 @@ public class ExtraVO implements Serializable { private boolean isSpecial; @ApiModelProperty("选项") - private List selection; + private List selection; } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java index 00aa21e..a504076 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/FaultSelectionVO.java @@ -13,4 +13,6 @@ import java.io.Serializable; @EqualsAndHashCode public class FaultSelectionVO extends SelectionVO implements Serializable { + private Object item; + } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java new file mode 100644 index 0000000..07d95d8 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteSelectionVO.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/31 09:15 + */ +public class RemoteSelectionVO extends SelectionVO implements Serializable { + + private Object item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java index b32cca2..9b0f7e0 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ScadaSelectionVO.java @@ -13,4 +13,6 @@ import java.io.Serializable; @EqualsAndHashCode public class ScadaSelectionVO extends SelectionVO implements Serializable { + private Object item; + } 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 99275b9..ef03d20 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 @@ -12,13 +12,14 @@ import java.util.Optional; */ @AllArgsConstructor public enum FuncRouteEnum { - OPEN_CANVAS("open_canvas","打开实时画面",null), - OPEN_VIDEO("open_video","打开视频监控",null), - DIAGNOSE("diagnose","智能诊断",null), - CHOOSE_STATION("choose_station","选择站点",null), - CHOOSE_VIDEO("choose_video","选择视频",null), - CHOOSE_CANVAS("choose_canvas","选择画面",null), - CHOOSE_FAULT("choose_fault","选择故障",null), + OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP), + OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS), + DIAGNOSE("diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS), + CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE), + CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 8c5999e..26f047e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -63,20 +63,17 @@ public class ExtraResolveStrategyService { switch (funcRouteEnum) { case DIAGNOSE: return this.resolveDiagnose(extra); - case CHOOSE_STATION: - return this.resolveChooseStation(extra); case CHOOSE_VIDEO: - return this.resolveChooseVideo(extra); case CHOOSE_CANVAS: - return this.resolveChooseScada(extra); + case CHOOSE_STATION: case CHOOSE_FAULT: - return this.resolveChooseFault(extra); + case CHOOSE_YC: + case CHOOSE_YK: + return this.resolveChooseSelection(extra,funcRouteEnum); case CONFIRM_YK: return this.resolveConfirmRemote(extra); case SHOW_PARAM: return this.resolveShowParam(extra); - case CHOOSE_YC: - return this.resolveChooseYc(extra); default: break; } @@ -88,19 +85,31 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } - private ExtraVO resolveChooseYc(JSONObject extra) { + private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) { ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - if(data.containsKey("ycs")) { - List attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class); - result.setSelection(attrs); - } - result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode()); + JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data"))); + result.setFuncCode(funcRouteEnum.getFuncCode()); result.setSpecial(true); - result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); + result.setSelection(selections); + result.setType(funcRouteEnum.getType().getType()); return result; } +// private ExtraVO resolveChooseYc(JSONObject extra) { +// ExtraVO result = new ExtraVO(); +// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); +// if(data.containsKey("yks")) { +// +// +// List attrs = JSONArray.parseArray(JSON.toJSONString(data.get("yks")), AttrSelectionVO.class); +// result.setSelection(attrs); +// } +// result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode()); +// result.setSpecial(true); +// result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); +// return result; +// } + private ExtraVO resolveShowParam(Map extra) { DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); if(Func.isNotEmpty(data)) { @@ -143,7 +152,7 @@ public class ExtraResolveStrategyService { result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); if(funcVOR.isSuccess()) { - Map param = new HashMap(1); + Map param = new HashMap(); param.put("control",funcVOR.getData()); param.put("deviceName",remoteParam.getDeviceName()); param.put("projectName",remoteParam.getProjectName()); @@ -154,18 +163,18 @@ public class ExtraResolveStrategyService { return result; } - private ExtraVO resolveChooseFault(Map extra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - if(data.containsKey("faults")) { - List faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); - result.setSelection(faults); - } - result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); - result.setSpecial(true); - result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); - return result; - } +// private ExtraVO resolveChooseFault(Map extra) { +// ExtraVO result = new ExtraVO(); +// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); +// if(data.containsKey("faults")) { +// List faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); +// result.setSelection(faults); +// } +// result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); +// result.setSpecial(true); +// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); +// return result; +// } private ExtraVO resolveDiagnose(Map extra) { ExtraVO result = new ExtraVO(); @@ -187,28 +196,28 @@ public class ExtraResolveStrategyService { * @param extra * @return */ - private ExtraVO resolveChooseStation(Map extra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - if(data.containsKey("stations")) { - List stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); - List selectionList = stations.stream().map(stationId -> { - StationSelectionVO selectionVO = new StationSelectionVO(); - R stationR = stationClient.getStationByCode(stationId); - if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) { - selectionVO.setId(stationId); - selectionVO.setName(stationR.getData().getName()); - } - return selectionVO; - }).collect(Collectors.toList()); - result.setSelection(selectionList); - result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode()); - result.setSpecial(true); - result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); - } - result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); - return result; - } +// private ExtraVO resolveChooseStation(Map extra) { +// ExtraVO result = new ExtraVO(); +// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); +// if(data.containsKey("stations")) { +// List stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); +// List selectionList = stations.stream().map(stationId -> { +// StationSelectionVO selectionVO = new StationSelectionVO(); +// R stationR = stationClient.getStationByCode(stationId); +// if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) { +// selectionVO.setId(stationId); +// selectionVO.setName(stationR.getData().getName()); +// } +// return selectionVO; +// }).collect(Collectors.toList()); +// result.setSelection(selectionList); +// result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode()); +// result.setSpecial(true); +// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); +// } +// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); +// return result; +// } private ExtraVO resolveChooseVideo(Map extra) { ExtraVO result = new ExtraVO(); 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 e956400..fc6337f 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 @@ -108,6 +108,7 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_STATION: case CHOOSE_YC: case CHOOSE_FAULT: + case CHOOSE_YK: this.handleDefaultChoose(messageContext,sessionId); break; case CHOOSE_VIDEO: @@ -126,10 +127,6 @@ public class InteractiveHandler extends TextWebSocketHandler { IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); String userId = messageContext.getString("userId"); String funcCode = messageContext.getString("funcCode"); - StationSelectionVO selectionVO = messageContext.getObject("selection",StationSelectionVO.class); - JSONObject data = new JSONObject(); - data.put("station_id",selectionVO.getId()); - data.put("station_name",selectionVO.getName()); Map extra = new HashMap<>(2); extra.put("func",funcCode); extra.put("data",messageContext.getObject("selection", JSONObject.class)); @@ -195,26 +192,4 @@ public class InteractiveHandler extends TextWebSocketHandler { } } - private void handleFaultChoose(JSONObject messageContext,String sessionId) { - IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - String userId = messageContext.getString("userId"); - String funcCode = messageContext.getString("funcCode"); - FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); - Map extra = new HashMap<>(2); - extra.put("func",funcCode); - extra.put("data",selectionVO); - interactiveService.specialAsk(sessionId,userId,extra); - } - - private void handleDataChoose(JSONObject messageContext,String sessionId) { - IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - String userId = messageContext.getString("userId"); - String funcCode = messageContext.getString("funcCode"); - FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); - Map extra = new HashMap<>(2); - extra.put("func",funcCode); - extra.put("data",selectionVO); - interactiveService.specialAsk(sessionId,userId,extra); - } - } diff --git a/pom.xml b/pom.xml index 7672dcf..fee8f9d 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - 5.1.1.RELEASE.fix.4 + 5.1.1.RELEASE.fix.5 com.xuxueli From 4e6a3e28f4133dd82040abd84ce23b2353aeb402 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 31 May 2024 15:51:39 +0800 Subject: [PATCH 113/151] =?UTF-8?q?fix=EF=BC=9A=E7=B3=BB=E7=BB=9F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=97=B6=E6=A0=BC=E5=BC=8F=E5=8C=96=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java | 6 ++++++ .../java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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 712b2bf..47908f1 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 @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springblade.core.tool.utils.BeanUtil; import java.io.Serializable; @@ -47,4 +48,9 @@ public class AnswerVO implements Serializable { @ApiModelProperty("其它调用的参数") private Object[] extras; + public static void error(AnswerVO usualVO) { + usualVO.setRunning(0); + usualVO.setStatus(-2); + } + } 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 759c3b8..32c132d 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 @@ -109,9 +109,9 @@ public class InteractiveSchedule { answerVO.setExtras(extraList.toArray(new String[extraList.size()])); } catch(Exception e) { - redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,answerVO.getSessionId()); e.printStackTrace(); - throw new RuntimeException(e); + AnswerVO.error(answerVO); + answerVO.setAnswer("非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"); } } if(sessionIds.contains(answerVO.getSessionId())){ From 350c494c18092d4d971259c9eacb74f876914a99 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 3 Jun 2024 14:37:09 +0800 Subject: [PATCH 114/151] =?UTF-8?q?update:=20=E8=BD=A6=E6=A3=80=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/entity/CarCheckTemplateDetailEntity.java | 4 ---- .../hzims/safeproduct/mapper/CarCheckTemplateMapper.xml | 4 ++-- .../service/impl/CarCheckRecordServiceImpl.java | 16 +--------------- .../safeproduct/src/main/resources/db/2.0.1.sql | 8 ++++---- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java index 97c666c..387b8a5 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java @@ -32,8 +32,4 @@ public class CarCheckTemplateDetailEntity extends BaseEntity { @NotNull @ApiModelProperty("检查内容") private String checkContent; - - @NotNull - @ApiModelProperty("检查结果") - private String checkResult; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml index 83f2b3b..cf3e0ba 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml @@ -6,11 +6,11 @@ SELECT * FROM - car_check_template_detail + hzims_car_check_template WHERE is_deleted = 0 - AND template_name like concate('%', #{param.templateName}, '%') + AND template_name like concat('%', #{param.templateName}, '%') ORDER BY create_time DESC diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java index 69ae394..ce72167 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java @@ -29,7 +29,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -106,19 +105,7 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckItemService.getListByCarCheckRecordId(id); - List checkItemList = new ArrayList<>(); - itemList.forEach(item -> { - String[] contents = item.getCheckContent().split(",|,"); - String[] results = item.getCheckResult().split(",|,"); - for (int i = 0; i < contents.length; i++) { - CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity(); - carCheckItemEntity.setCheckItem(item.getCheckItem()); - carCheckItemEntity.setCheckContent(contents[i]); - carCheckItemEntity.setCheckResult(results[i]); - checkItemList.add(carCheckItemEntity); - } - }); - carCheckRecordDetailVO.setCheckItemList(checkItemList); + carCheckRecordDetailVO.setCheckItemList(itemList); return carCheckRecordDetailVO; } return null; @@ -187,7 +174,6 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); itemList.forEach(x -> { x.setCarCheckRecordId(carCheckRecordDTO.getId()); -// x.setId(null); }); return carCheckItemService.saveBatch(itemList); } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 733ffca..4c2497b 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -49,7 +49,7 @@ ALTER TABLE hzims_test ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分'; -- 新增车检模板表 -CREATE TABLE IF NOT EXISTS `hzims_hygiene_template` ( +CREATE TABLE IF NOT EXISTS `hzims_car_check_template` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_name` varchar(50) NOT NULL COMMENT '模板名称', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', @@ -60,10 +60,10 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板表'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板表'; -- 新增车检模板详情表 -CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( +CREATE TABLE IF NOT EXISTS `hzims_car_check_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `check_item` varchar(500) NOT NULL COMMENT '检查项目', @@ -76,4 +76,4 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板详情表'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板详情表'; \ No newline at end of file From 904bbd2eb1a6593c554125d47f331a9322e8585b Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 3 Jun 2024 14:37:31 +0800 Subject: [PATCH 115/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=AB?= =?UTF-8?q?=E7=94=9F=E6=A8=A1=E6=9D=BF=E6=9F=A5=E8=AF=A2=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml index cdb1378..c4edda8 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml @@ -9,7 +9,7 @@ WHERE is_deleted = 0 - AND template_name like concate('%', #{param.templateName}, '%') + AND template_name like concat('%', #{param.templateName}, '%') ORDER BY create_time DESC From 693132b15b03fef99f329abe00bd9bdd6172a83c Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 3 Jun 2024 17:34:32 +0800 Subject: [PATCH 116/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=BC=94?= =?UTF-8?q?=E7=BB=83=E3=80=81=E5=9F=B9=E8=AE=AD=E3=80=81=E5=8D=AB=E7=94=9F?= =?UTF-8?q?=E6=9C=88=E5=BA=A6=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/controller/HygieneController.java | 15 ++++++++++ .../controller/RehearsalController.java | 18 ++++++++++-- .../safeproduct/controller/TrainController.java | 18 ++++++++++-- .../hzims/safeproduct/mapper/TrainPlanMapper.xml | 11 +++---- .../safeproduct/service/IHygienePlanService.java | 8 +++++ .../safeproduct/service/IRehearsalPlanService.java | 8 +++++ .../safeproduct/service/ITrainPlanService.java | 8 +++++ .../service/impl/HygienePlanServiceImpl.java | 33 +++++++++++++++++++++ .../service/impl/RehearsalPlanServiceImpl.java | 33 +++++++++++++++++++-- .../service/impl/TrainPlanServiceImpl.java | 34 ++++++++++++++++++++++ 10 files changed, 173 insertions(+), 13 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index 8290da9..1c4de51 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -230,4 +230,19 @@ public class HygieneController extends BladeController { IPage page = hygieneTemplateService.getHygieneTemplatePage(param, query); return R.data(page); } + + @GetMapping("/detailListByMonth") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "hygienePlanStatus", value = "卫生计划状态", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "卫生月度详情列表") + @ApiOperationSupport(order = 20) + @Operate(label = "卫生月度详情列表", type = BusinessType.QUERY, ignore = false) + public R> detailListByMonth(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = hygienePlanService.getDetailListByMonth(param, query); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java index 14cdc89..08d28ce 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -82,8 +82,7 @@ public class RehearsalController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "rehearsalStatus", value = "演练状态", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "演练计划分页") @ApiOperationSupport(order = 5) @@ -178,4 +177,19 @@ public class RehearsalController extends BladeController { public void exportRehearsalRecordData(@RequestParam Long id, HttpServletResponse response) { rehearsalRecordService.exportRehearsalRecordData(id, response); } + + @GetMapping("/detailListByMonth") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "rehearsalStatus", value = "演练状态", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练月度详情列表") + @ApiOperationSupport(order = 15) + @Operate(label = "演练月度详情列表", type = BusinessType.QUERY, ignore = false) + public R> detailListByMonth(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalPlanService.getDetailListByMonth(query, param); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index 7eda44c..ef252f9 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -91,8 +91,7 @@ public class TrainController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "trainStatus", value = "培训计划状态", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) @@ -276,4 +275,19 @@ public class TrainController extends BladeController { public void exportTrainRecordData(@RequestParam Long id, HttpServletResponse response) { trainRecordService.exportTrainRecordData(id, response); } + + @GetMapping("/detailListByMonth") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "trainStatus", value = "培训计划状态", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "培训月度详情列表") + @ApiOperationSupport(order = 24) + @Operate(label = "培训月度详情列表", type = BusinessType.QUERY, ignore = false) + public R> detailListByMonth(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = trainPlanService.getDetailListByMonth(param, query); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml index 19ef188..45cc431 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml @@ -81,14 +81,11 @@ AND unit like concat('%', #{param.unit}, '%') - - AND scheduled_start_time >= #{param.startTime} + + AND scheduled_start_time >= #{param.scheduledStartTime} - - AND scheduled_end_time <= #{param.endTime} - - - AND train_status = #{param.trainStatus} + + AND scheduled_end_time <= #{param.scheduledEndTime} ORDER BY create_time DESC diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java index a564531..484cfcf 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java @@ -92,4 +92,12 @@ public interface IHygienePlanService extends IService { * @param response 响应类 */ void exportHygienePlanData(Map param, HttpServletResponse response); + + /** + * 查询卫生月度详情列表 + * @param param 参数 + * @param query 分页类 + * @return 月度详情列表 + */ + IPage getDetailListByMonth(Map param, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java index d679fc0..7745227 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java @@ -66,4 +66,12 @@ public interface IRehearsalPlanService extends IService { * @return 演练计划数据 */ IPage rehearsalPlanPage(Map param, Query query); + + /** + * 查询月度详情列表 + * @param query 分页类 + * @param param 参数 + * @return 详情列表 + */ + IPage getDetailListByMonth(Query query, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java index 75e86ed..1aa7ad7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java @@ -66,4 +66,12 @@ public interface ITrainPlanService extends IService { * @return 培训计划数据 */ IPage trainPlanPage(Map param, Query query); + + /** + * 查询培训月度详情列表 + * @param param 参数 + * @param query 分页类 + * @return 月度详情列表 + */ + IPage getDetailListByMonth(Map param, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index d0d3b88..ea4d1a0 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -371,6 +371,39 @@ public class HygienePlanServiceImpl extends ServiceImpl getDetailListByMonth(Map param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + String hygieneStatus = String.valueOf(param.get("hygienePlanStatus")); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().like(HygienePlanEntity::getUnit, unit); + } + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(HygienePlanEntity::getScheduledEndTime, startTime); + } + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(HygienePlanEntity::getScheduledEndTime, endTime); + } + if (!hygieneStatus.equals("null") && !hygieneStatus.equals("")) { + // 未完成计划包括UNFINISHED和WAITING两种状态 + if (hygieneStatus.equals("UNFINISHED+WAITING")) { + queryWrapper.lambda().and(wrapper -> wrapper.eq(HygienePlanEntity::getHygienePlanStatus, HygieneStatusEnum.UNFINISHED.getValue()) + .or() + .eq(HygienePlanEntity::getHygienePlanStatus, HygieneStatusEnum.WAITING.getValue())); + } else { + queryWrapper.lambda().eq(HygienePlanEntity::getHygienePlanStatus, hygieneStatus); + } + } + queryWrapper.lambda().orderByDesc(HygienePlanEntity::getCreateTime); + return this.page(Condition.getPage(query), queryWrapper); + } + + /** * 根据单位、名称、时间查询卫生自查计划 * @param unit 单位 * @param name 名称 diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index 9cd63ef..08c858e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -276,7 +276,6 @@ public class RehearsalPlanServiceImpl extends ServiceImpl getDetailListByMonth(Query query, Map param) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + String rehearsalStatus = String.valueOf(param.get("rehearsalStatus")); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit); + } + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledEndTime, startTime); + } + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime); + } if (!rehearsalStatus.equals("null") && !rehearsalStatus.equals("")) { - queryWrapper.lambda().eq(RehearsalPlanEntity::getRehearsalStatus, rehearsalStatus); + // 未完成计划包括UNFINISHED和WAITING两种状态 + if (rehearsalStatus.equals("UNFINISHED+WAITING")) { + queryWrapper.lambda().and(wrapper -> wrapper.eq(RehearsalPlanEntity::getRehearsalStatus, RehearsalStatusEnum.UNFINISHED.getValue()) + .or() + .eq(RehearsalPlanEntity::getRehearsalStatus, RehearsalStatusEnum.WAITING.getValue())); + } else { + queryWrapper.lambda().eq(RehearsalPlanEntity::getRehearsalStatus, rehearsalStatus); + } } queryWrapper.lambda().orderByDesc(RehearsalPlanEntity::getCreateTime); return this.page(Condition.getPage(query), queryWrapper); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java index 3f3af95..40fb225 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; @@ -268,6 +269,39 @@ public class TrainPlanServiceImpl extends ServiceImpl getDetailListByMonth(Map param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + String trainStatus = String.valueOf(param.get("trainStatus")); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().like(TrainPlanEntity::getUnit, unit); + } + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(TrainPlanEntity::getScheduledEndTime, startTime); + } + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime); + } + if (!trainStatus.equals("null") && !trainStatus.equals("")) { + // 未完成计划包括UNFINISHED和WAITING两种状态 + if (trainStatus.equals("UNFINISHED+WAITING")) { + queryWrapper.lambda().and(wrapper -> wrapper.eq(TrainPlanEntity::getTrainStatus, TrainStatusEnum.UNFINISHED.getValue()) + .or() + .eq(TrainPlanEntity::getTrainStatus, TrainStatusEnum.WAITING.getValue())); + } else { + queryWrapper.lambda().eq(TrainPlanEntity::getTrainStatus, trainStatus); + } + } + queryWrapper.lambda().orderByDesc(TrainPlanEntity::getCreateTime); + return this.page(Condition.getPage(query), queryWrapper); + } + + /** * 根据单位和计划时间查询培训计划数据 * @param unit 单位 * @param startTime 计划开始时间 From 98330e808ad8552670ebdc3720541f4dcb096388 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 6 Jun 2024 15:06:56 +0800 Subject: [PATCH 117/151] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=81=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=8B=E9=99=90=E6=B0=B4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/operational/main/vo/RealStationVo.java | 3 +++ .../hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java | 2 +- .../hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java | 5 ++--- .../service/operation/monitor/impl/MonitorServiceImpl.java | 1 + .../station/service/impl/RealMonitorServiceImpl.java | 11 ++++++----- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java index 326fb58..7943bcb 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java @@ -34,6 +34,9 @@ public class RealStationVo implements Serializable { @ApiModelProperty("最大前池水位") private Double waterLevelMax; + @ApiModelProperty("下限前池水位") + private Double downWaterLevel; + @ApiModelProperty("前池水位") private Double waterLevel; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java index 15e3cf7..bdaa7dd 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -58,7 +58,7 @@ public class MonitorScheduledTask { * @return ReturnT */ @XxlJob(CENTRALIZED_MONITORING) - //@Scheduled(cron = "0/40 * * * * ? ") + // @Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadMonitoring(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 69c643c..6c811ef 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -27,7 +27,6 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.mqtt.producer.IMqttSender; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -55,7 +54,7 @@ public class AlarmServiceImpl implements AlarmService { private final RedisTemplate redisTemplate; - private final IMqttSender mqttSender; + //private final IMqttSender mqttSender; private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; @@ -277,7 +276,7 @@ public class AlarmServiceImpl implements AlarmService { alarm.setContext(entity.getStationName() + "." + entity.getSoeExplain()); alarm.setState(entity.getStatus()); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); - mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); + //mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); }); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 13b41ce..0547edb 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -500,6 +500,7 @@ public class MonitorServiceImpl implements MonitorService { } realStation.setStationCode(optional.get().getCode()); realStation.setStationName(optional.get().getName()); + realStation.setDownWaterLevel(Optional.ofNullable(optional.get().getDownWaterLevel()).orElse(0.0)); realStation.setWaterLevelMax(Optional.ofNullable(optional.get().getLimitWaterLevel()).orElse(0.0)); realStation.setServerType(optional.get().getServeType()); realStation.setStationDeptId(optional.get().getRefDept()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index 7e38882..bda8eed 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -258,7 +258,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService { if(ObjectUtil.isEmpty(o.getSort())){ o.setSort(999); } - }).sorted(Comparator.comparing((RealStationVo::getSort))).collect(Collectors.toList()))); + }).sorted(Comparator.comparing((RealStationVo::getSort)).thenComparing(RealStationVo::getStationName)).collect(Collectors.toList()))); } /** @@ -326,7 +326,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService { * @param station */ private void waterLevel(List list, RealStationVo station) { - station.setWaterLevel(0.0); + Random random = new Random(); + station.setWaterLevel(random.nextDouble() * 10); station.setWaterColor(0); if(CollectionUtil.isEmpty(list)){ return; @@ -336,12 +337,12 @@ public class RealMonitorServiceImpl implements IRealMonitorService { return; } station.setWaterLevel(levelList.get(0)); - if(ObjectUtil.isEmpty(station.getWaterLevelMax()) || ObjectUtil.isEmpty(station.getWaterLevel()) || station.getWaterLevelMax() <= 0 || station.getWaterLevel() <= 0){ + if(station.getWaterLevel() <= 0){ return; } - if(station.getWaterLevelMax() < station.getWaterLevel()){ + if(station.getWaterLevelMax() < station.getWaterLevel() || station.getDownWaterLevel() > station.getWaterLevel()){ station.setWaterColor(2); - }else if((station.getWaterLevel() / station.getWaterLevelMax()) > 0.8){ + }else if((station.getWaterLevelMax() > 0 && (station.getWaterLevel() / station.getWaterLevelMax()) > 0.8) || (station.getDownWaterLevel() > 0 && (station.getWaterLevel() / station.getDownWaterLevel()) < 1.2)){ station.setWaterColor(1); } } From 66431977245d0a30d4797e7fca7ae3dd624770ac Mon Sep 17 00:00:00 2001 From: liwen Date: Fri, 7 Jun 2024 10:24:48 +0800 Subject: [PATCH 118/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=A6?= =?UTF-8?q?=E6=A3=80=E8=AE=B0=E5=BD=95=E5=AF=BC=E5=87=BA=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CarCheckRecordServiceImpl.java | 16 ++++++++++++++++ .../java/com/hnac/hzims/safeproduct/utils/BaseUtil.java | 3 +++ 2 files changed, 19 insertions(+) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java index ce72167..2ddad1b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -198,6 +199,21 @@ public class CarCheckRecordServiceImpl extends ServiceImpl checkList = carCheckRecordDetailVO.getCheckItemList(); + List res = new ArrayList<>(); + checkList.forEach(item -> { + String[] checkContent = item.getCheckContent().split(","); + String[] checkResult = item.getCheckResult().split(","); + for (int i = 0; i < checkContent.length; i++) { + CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity(); + carCheckItemEntity.setCheckItem(item.getCheckItem()); + carCheckItemEntity.setCheckContent(checkContent[i]); + carCheckItemEntity.setCheckResult(checkResult[i]); + res.add(carCheckItemEntity); + } + }); + carCheckRecordDetailVO.setCheckItemList(res); // 表头年月 String code = carCheckRecordDetailVO.getCode(); carCheckRecordDetailVO.setYear(code.substring(4, 8)); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index 76aada7..c80b1ba 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -147,6 +147,9 @@ public class BaseUtil { if (templatePath.equals("template/卫生自查表.docx")) { formatHygieneRecordTable(xwpfDocument); } + if (templatePath.equals("template/车辆检查表.docx")) { + formatCarCheckRecordTable(xwpfDocument); + } } catch (Exception e) { e.printStackTrace(); } From 11fd53b911662e5d8b40d95371a432def4fa1e06 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 12 Jun 2024 16:33:42 +0800 Subject: [PATCH 119/151] =?UTF-8?q?fix=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=83=AD=E7=82=B9=E9=97=AE=E9=A2=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 ++ .../controller/InteractiveController.java | 16 +++++++++++++++ .../interactive/service/IInteractiveService.java | 6 ++++++ .../service/impl/InteractiveServiceImpl.java | 24 ++++++++++++++++++++++ .../hzims/bigmodel/interactive/vo/AnswerVO.java | 9 +++++++- 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 8179cba..996a155 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -28,4 +28,6 @@ public class BigModelInvokeUrl { private String updateCanvas; private String assistantKnowledgeAsk; + + private String hotQuestion; } 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 c109e57..26edbdf 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.controller; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; @@ -16,6 +17,7 @@ import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.*; import java.text.DecimalFormat; +import java.util.List; /** * @Author: huangxing @@ -92,4 +94,18 @@ public class InteractiveController { DecimalFormat format = new DecimalFormat("0.00"); return R.data(format.format(generate) + "kWh"); } + + @ApiOperation("获取热点问题") + @ApiOperationSupport(order = 8) + @GetMapping("/hotQuestions") + public R hotQuestions() { + try{ + List questions = interactiveService.hotQuestions(); + return R.data(questions); + } + catch (Exception e) { + e.printStackTrace(); + return R.data(Lists.newArrayList()); + } + } } 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 c6433df..9474795 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 @@ -48,4 +48,10 @@ public interface IInteractiveService { R sendRemoteControl(ControlDTO operate); Double generation(String stationId, String startTime, String endTime); + + /** + * 获取热点问题 + * @return 热点问题 + */ + List hotQuestions(); } 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 2fd2480..d670ef6 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 @@ -37,6 +37,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; +import org.apache.poi.ss.formula.functions.T; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; @@ -196,6 +197,29 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override + public List hotQuestions() { + String url = fdpHost + bigModelInvokeUrl.getHotQuestion(); + return this.postCall(url,null,List.class); + } + + /** + * 远程调用http接口 + * @param url 接口url + * @param body 传参 + * @param resultT 结果解析对象 + * @return 结果 + * @param 结果解析对象类型 + */ + public T postCall(String url,Map body,Class resultT) { + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + log.error("远程调用大模型接口" + url + "失败!"); + throw new ServiceException("远程调用大模型接口" + url + "失败!"); + }); + return JSONObject.parseObject(response.body(),resultT); + } + + @Override public void updateVideo(Map request) { HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo()) .body(JSON.toJSONString(request)).execute(); 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 47908f1..29baf54 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 @@ -48,9 +48,16 @@ public class AnswerVO implements Serializable { @ApiModelProperty("其它调用的参数") private Object[] extras; + @ApiModelProperty("用于语音回复的状态文本") + @JSONField(name = "voice_text") + private String[] voiceText; + + @ApiModelProperty("用于语音回复的答案") + @JSONField(name = "voice_answer") + private String[] voiceAnswer; + public static void error(AnswerVO usualVO) { usualVO.setRunning(0); usualVO.setStatus(-2); } - } From c21c0e222c302c8dc1313f8be7da6fd6f35d8ff9 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 13 Jun 2024 17:20:45 +0800 Subject: [PATCH 120/151] =?UTF-8?q?fix=EF=BC=9A=E6=97=A5=E5=B8=B8=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E4=BB=BB=E5=8A=A1=E9=80=BE=E6=9C=9F=E6=8F=90=E9=86=92?= =?UTF-8?q?=E5=8F=AA=E6=8F=90=E9=86=92=E6=9C=AC=E7=BA=A7=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=8F=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java index 534545f..410d924 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java @@ -87,7 +87,7 @@ public class MaintenanceTaskRemindHandler { XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!"); } // 任务执行人发送短信 - R> listR = userClient.relationUserListByRoleAlias(CommonConstant.TENANT_ID, taskEntity.getCreateDept(), RoleAliasConstants.PROJECT_MANAGER); + R> listR = userClient.queryUserByRoleAlias(CommonConstant.TENANT_ID, taskEntity.getCreateDept(), RoleAliasConstants.PROJECT_MANAGER); if(listR.isSuccess()) { request.setUserIds(listR.getData().stream().map(User::getId).map(String::valueOf).collect(Collectors.joining(","))); request.setContent("有一条待执行的日常维护任务【"+taskEntity.getTitle()+"】即将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME) +"过期,请确认。"); From 6107ee9dc87e0ae2663f631884b0d01d3e4669bd Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 12 Jun 2024 08:34:16 +0800 Subject: [PATCH 121/151] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3=E5=9B=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E8=BD=AE=E8=AF=A2=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=AF=BC=E8=87=B4resource=E6=9C=8D=E5=8A=A1=E7=86=94?= =?UTF-8?q?=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/message/fegin/MessageClient.java | 5 +--- .../hzims/message/service/IMessageService.java | 4 +-- .../service/impl/MailMessageServiceImpl.java | 8 +++++- .../service/impl/SmsMessageServiceImpl.java | 29 ++++++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java index c605947..4259974 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java @@ -179,9 +179,6 @@ public class MessageClient extends BladeController implements IMessageClient{ try { for (Long pushId : Func.toLongList(",", smsImmediatelyPushDTO.getPusher())) { User user = UserCache.getUser(pushId); - if (ObjectUtil.isEmpty(user)||ObjectUtil.isEmpty(user.getPhone())){ - continue; - } MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO, MessagePushRecordEntity.class); record.setMessageId(IdWorker.getId()); record.setPusherName(user.getRealName()); @@ -199,7 +196,7 @@ public class MessageClient extends BladeController implements IMessageClient{ record.setSmsParam(JSON.toJSONString(params)); Boolean flag = recordService.sendSmsImmediatelyMsg(record); if (!flag) { - log.error("短信推送失败,参数:" + record.toString()); + log.error("短信推送失败,参数:{}", JSON.toJSONString(record)); } } return R.data(true); diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java index 184e7c7..0c5a7d1 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java @@ -35,9 +35,9 @@ public interface IMessageService { if(ObjectUtil.isNotEmpty(user)) { switch(type) { case MAIL_PUSH: - return Func.isNotEmpty(user.getEmail()) ? user.getEmail() : Long.toString(pusher); + return user.getEmail(); case SMS_PUSH: - return Func.isNotEmpty(user.getPhone()) ? user.getPhone() : Long.toString(pusher); + return user.getPhone(); default: break; } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java index 414d532..53dc85f 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java @@ -13,12 +13,14 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import org.springframework.web.multipart.MultipartFile; import javax.mail.MessagingException; @@ -79,6 +81,10 @@ public class MailMessageServiceImpl implements IMessageService { @Override public boolean send(MessagePushRecordEntity request) { + String account = getAccountByPusher(Long.parseLong(request.getPusher()), request.getType()); + Assert.isTrue(Func.isNotEmpty(account) && StringUtil.isNotBlank(account) , () -> { + throw new ServiceException("未查询到相关用户,邮件推送失败!"); + }); // 创建复杂有限发送对象 MimeMessage mimeMessage = mailSender.createMimeMessage(); MimeMessageHelper messageHelper; @@ -87,7 +93,7 @@ public class MailMessageServiceImpl implements IMessageService { // 设置发件人邮箱(若配置默认邮箱则不用再设置) messageHelper.setFrom(fromAccount); // 设置收件人邮箱 - messageHelper.setTo(getAccountByPusher(Long.parseLong(request.getPusher()),request.getType())); + messageHelper.setTo(account); // 设置抄报人邮箱(可以不填写) if(StringUtil.isNotBlank(request.getCcAccount())) { messageHelper.setCc(request.getCcAccount()); diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java index 29bdb30..be5d801 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java @@ -15,6 +15,7 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.sms.model.SmsResponse; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.resource.feign.ISmsClient; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -48,11 +49,15 @@ public class SmsMessageServiceImpl implements IMessageService { @Override public boolean send(MessagePushRecordEntity request) { + String account = this.getAccountByPusher(Long.parseLong(request.getPusher()), request.getType()); + Assert.isTrue(Func.isNotEmpty(account) && StringUtil.isNotBlank(account) ,() -> { + throw new ServiceException("未查询到相关用户,短信推送失败!"); + }); R response = smsClient.sendMessage( - Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), - request.getResourceCode(), - request.getSmsParam(), - this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType()) + Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), + request.getResourceCode(), + request.getSmsParam(), + account ); if(ObjectUtils.isEmpty(response.getData())) { Assert.isTrue(response.isSuccess(), () -> { @@ -68,11 +73,15 @@ public class SmsMessageServiceImpl implements IMessageService { } public R sendSmsByRecord(MessagePushRecordEntity request) { - return smsClient.sendMessage( - Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), - request.getResourceCode(), - request.getSmsParam(), - this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType()) - ); + String account = this.getAccountByPusher(Long.parseLong(request.getPusher()), request.getType()); + if(Func.isNotEmpty(account) && StringUtil.isNotBlank(account)) { + return smsClient.sendMessage( + Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), + request.getResourceCode(), + request.getSmsParam(), + account + ); + } + return R.fail("未查询到相关用户,短信推送失败!"); } } From a84e3e7b4e8e0d1efb588c5507a9b346c656ab6f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 13 Jun 2024 19:49:55 +0800 Subject: [PATCH 122/151] =?UTF-8?q?fix=EF=BC=9A=E6=97=A5=E5=B8=B8=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E4=BB=BB=E5=8A=A1=E9=80=BE=E6=9C=9F=E6=8F=90=E9=86=92?= =?UTF-8?q?=E5=8F=AA=E6=8F=90=E9=86=92=E6=9C=AC=E7=BA=A7=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=8F=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/scheduled/MaintenanceTaskRemindHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java index 410d924..68d0739 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java @@ -83,7 +83,7 @@ public class MaintenanceTaskRemindHandler { request.setCreateUser(taskEntity.getCreateUser()); request.setTenantId(CommonConstant.TENANT_ID); R sendFlag = messageClient.sendAppAndWsMsgByUsers(request); - if(!sendFlag.isSuccess() || sendFlag.getData() == null) { + if(!sendFlag.isSuccess()) { XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!"); } // 任务执行人发送短信 @@ -92,7 +92,7 @@ public class MaintenanceTaskRemindHandler { request.setUserIds(listR.getData().stream().map(User::getId).map(String::valueOf).collect(Collectors.joining(","))); request.setContent("有一条待执行的日常维护任务【"+taskEntity.getTitle()+"】即将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME) +"过期,请确认。"); R result = messageClient.sendAppAndWsMsgByUsers(request); - if(!result.isSuccess() || result.getData() == null) { + if(!result.isSuccess()) { XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!"); } } From 7c165fbc499ebe5e4d09c2ebea03ff8c7b84e019 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 20 Jun 2024 17:07:39 +0800 Subject: [PATCH 123/151] =?UTF-8?q?#=E4=BA=91=E6=9C=8D=E5=8A=A1=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java index 0550817..eda0431 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java @@ -139,7 +139,7 @@ public class DeptServiceImpl implements IDeptService { @Override public List alarmDeptByCurrentUser() { List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType, HomePageConstant.HYDROPOWER) ); if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); From ebda84b0c163a44a3454de1135a00715e795d676 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 21 Jun 2024 14:21:55 +0800 Subject: [PATCH 124/151] =?UTF-8?q?#=E4=B8=8B=E9=99=90=E6=B0=B4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/operational/station/entity/StationEntity.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java index 4d93882..34e6b42 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java @@ -99,6 +99,11 @@ public class StationEntity extends TenantEntity implements Serializable { @TableField(updateStrategy = FieldStrategy.IGNORED) private Double waterLevelMax; + @ApiModelProperty("前池下限水位") + @JsonSerialize(nullsUsing = NullSerializer.class) + @TableField(updateStrategy = FieldStrategy.IGNORED) + private Double downWaterLevel; + @ApiModelProperty("经度(东经)") @JsonSerialize(nullsUsing = NullSerializer.class) private Float lgtd; From 19908d620129a4f414d3375f33a968ee91511172 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 21 Jun 2024 14:25:40 +0800 Subject: [PATCH 125/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=89=B4=E6=9D=83=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=20fix?= =?UTF-8?q?=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/DataAuthTypeEnum.java | 27 ++++++++++ .../controller/HznlmInteractiveController.java | 41 +++++++++++++++ .../controller/InteractiveController.java | 1 + .../bigmodel/interactive/dto/AuthDataDTO.java | 36 ++++++++++++++ .../service/IHznlmInteractiveService.java | 18 +++++++ .../service/impl/AnalyseDataServiceImpl.java | 57 +++++++++++++-------- .../service/impl/ExtraResolveStrategyService.java | 1 + .../service/impl/HzllmInteractiveServiceImpl.java | 58 ++++++++++++++++++++++ .../hzims/bigmodel/interactive/vo/AuthDataVO.java | 27 ++++++++++ .../interactive/vo/HistoryDataSearchVO.java | 2 + .../hzims/simulate/mapper/DeviceFieldGapMapper.xml | 18 ------- .../simulate/mapper/IHzllmInteractiveService.xml | 18 +++++++ 12 files changed, 264 insertions(+), 40 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java delete mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml create mode 100644 hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java new file mode 100644 index 0000000..ad3bb77 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DataAuthTypeEnum.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:49 + */ +@AllArgsConstructor +@Getter +public enum DataAuthTypeEnum { + /**站点鉴权**/ + STATION("station"), + DEPT("dept"), + ; + private final String type; + + public static DataAuthTypeEnum getEnumByType(String type) { + Optional typeEnumOptional = Arrays.stream(DataAuthTypeEnum.class.getEnumConstants()).filter(e -> e.getType().equals(type)).findFirst(); + return typeEnumOptional.orElse(null); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java new file mode 100644 index 0000000..2b125a9 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.bigmodel.interactive.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; +import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:21 + */ +@RestController +@AllArgsConstructor +@Api(value = "HZLLM大模型交互层",tags = "HZLLM大模型交互层") +@RequestMapping("/hzn_lm/interactive") +@Business(module = BigModelConstants.MODULE_NAME,value = "HZLLM大模型交互层") +public class HznlmInteractiveController { + + private final IHznlmInteractiveService interactiveService; + + @RequestMapping(value = "/get_auth_data",method = {RequestMethod.GET,RequestMethod.POST}) + @ApiOperation("获取鉴权数据") + @ApiOperationSupport(order = 1) + public R> getAuthData(@RequestBody @Valid AuthDataDTO req) { + return R.data(interactiveService.getAuthData(req)); + } + +} 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 26edbdf..7305f78 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,6 +48,7 @@ public class InteractiveController { @ApiOperation("站点、菜单鉴权") @ApiOperationSupport(order = 3) + @Deprecated @RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST}) public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("用户ID") String userId, diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java new file mode 100644 index 0000000..3d4fba5 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.bigmodel.interactive.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:39 + */ +@Data +@ApiModel(value = "获取权限接口传参格式",description = "获取权限接口传参格式") +@EqualsAndHashCode +public class AuthDataDTO implements Serializable { + + @JsonProperty("chat_id") + @ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据") + @NotBlank + private String sessionId; + + @JsonProperty("user_id") + @ApiModelProperty("提问用户ID") + @NotBlank + private String userId; + + @ApiModelProperty("鉴权类型") + @NotBlank + private String type; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java new file mode 100644 index 0000000..f134480 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.validation.Valid; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:23 + */ +public interface IHznlmInteractiveService { + + List getAuthData(@RequestBody @Valid AuthDataDTO req); + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index aac20c6..1d574b1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -19,6 +19,7 @@ import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; @@ -63,30 +64,46 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); Map params = new HashMap<>(1); - ReductionDataVO dataVO = this.getPolymerizationData(searchVO); - List datalist = dataVO.getDataList().stream().map(m -> { - m.put("val", m.get(searchVO.getSignage())); - m.remove(searchVO.getSignage()); - return m; - }).collect(Collectors.toList()); - DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); - String label = searchVO.getStationName() + "_" - + searchVO.getDeviceName() + "_" - + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" - + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) - + enumByMethod.getMethod() - + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) - + ":"; + Result reductionDataVOR = this.getPolymerizationData(searchVO); + String label; + if(!reductionDataVOR.isSuccess()) { + params.put("errorInfo",reductionDataVOR.getMsg()); + label = "查询数据失败!"; + } + else { + ReductionDataVO dataVO = reductionDataVOR.getData(); + label = "暂未查到数据"; + params.put("data",Lists.newArrayList()); + if(Func.isNotEmpty(dataVO) && CollectionUtil.isNotEmpty(dataVO.getDataList())) { + List datalist = dataVO.getDataList().stream().map(m -> { + m.put("val", m.get(searchVO.getSignage())); + m.remove(searchVO.getSignage()); + return m; + }).collect(Collectors.toList()); + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + if(CollectionUtil.isNotEmpty(datalist)) { + label = searchVO.getStationName() + "_" + + searchVO.getDeviceName() + "_" + + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) + + enumByMethod.getMethod() + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) + + ":"; + } + params.put("data",datalist); + } + } extraVO.setLabel(label); - params.put("data",datalist); params.put("deviceName",searchVO.getDeviceName()); - params.put("attrName",dataVO.getFieldMap().get(searchVO.getSignage())); + params.put("attrName",searchVO.getAttrName()); params.put("stationName",searchVO.getStationName()); + params.put("beginTime",searchVO.getStartTime()); + params.put("endTime",searchVO.getEndTime()); extraVO.setParams(params); return extraVO; } - private ReductionDataVO getPolymerizationData(HistoryDataSearchVO searchVO) { + private Result getPolymerizationData(HistoryDataSearchVO searchVO) { DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); @@ -106,11 +123,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { dataDTO.setTimeInterval(1); dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); - Result dataVO = deviceDataClient.pageDeviceCodeAndSignages(dataDTO); - Assert.isTrue(dataVO.isSuccess(),() -> { - throw new ServiceException("聚合历史数据查询失败!"); - }); - return dataVO.getData(); + return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); } private DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 26f047e..2a59476 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -125,6 +125,7 @@ public class ExtraResolveStrategyService { DataItemVO item = data.getItem(); HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); searchVO.setDataType(data.getDataType()); + searchVO.setAttrName(item.getAttrName()); searchVO.setDeviceCode(item.getDeviceId()); searchVO.setDeviceName(item.getDeviceName()); searchVO.setStationName(item.getProjectName()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java new file mode 100644 index 0000000..668bd66 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java @@ -0,0 +1,58 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum; +import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; +import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.dto.DeptStationDTO; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class HzllmInteractiveServiceImpl implements IHznlmInteractiveService { + + private final AuthenticationService authenticationService; + + @Override + public List getAuthData(AuthDataDTO req) { + DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType()); + switch(authTypeEnum) { + case STATION: + return this.getStationAuthData(req.getUserId()); + case DEPT: + return this.getDeptAuthData(req.getUserId()); + default: + throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持"); + } + } + + public List getDeptAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); + } + + public List getStationAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getId())).collect(Collectors.toList()); + } + + private AuthDataVO convertStationAuthData(DeptStationDTO req) { + return new AuthDataVO(req.getStationId(),req.getDeptName()); + } + + private AuthDataVO convertDeptAuthData(DeptStationDTO req) { + return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName()); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java new file mode 100644 index 0000000..a74f920 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:26 + */ +@Data +@AllArgsConstructor +@ApiModel(value = "鉴权数据VO",description = "鉴权数据VO,包含站点、机构、遥控权限") +@EqualsAndHashCode +public class AuthDataVO implements Serializable { + + @ApiModelProperty("数据ID") + private String id; + + @ApiModelProperty("数据名称") + private String name; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java index b6ea2f9..0728206 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/HistoryDataSearchVO.java @@ -23,6 +23,8 @@ public class HistoryDataSearchVO { @NotBlank private String signage; + private String attrName; + @NotBlank private String method; diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml deleted file mode 100644 index 7a4fff8..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - UPDATE HZINFO_FAC_DEVICE_ATTR_GAP - SET max_val = #{maxValue}, - min_val = #{minValue} - WHERE id = #{id} - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml new file mode 100644 index 0000000..7a4fff8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml @@ -0,0 +1,18 @@ + + + + + + + UPDATE HZINFO_FAC_DEVICE_ATTR_GAP + SET max_val = #{maxValue}, + min_val = #{minValue} + WHERE id = #{id} + + From 0ad88543060e782e47696b3294dadd09a7c5bb62 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 22 Jun 2024 17:02:50 +0800 Subject: [PATCH 126/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FunctionConstants.java | 38 ------- .../interactive/constants/FunctionConstants.java | 38 +++++++ .../interactive/constants/InfoMessageConstant.java | 11 ++ .../interactive/factory/AnswerResolveFactory.java | 46 ++++++++ .../interactive/factory/ResolveFactory.java | 44 ++++++++ .../interactive/service/IAnswerResolveService.java | 22 ++++ .../service/IHznlmInteractiveService.java | 3 + .../interactive/service/IHznlmInvokeService.java | 63 +++++++++++ .../interactive/service/IInteractiveService.java | 1 + .../interactive/service/IJumpPageService.java | 1 + .../interactive/service/IParamsService.java | 1 + .../interactive/service/IResolveService.java | 17 +++ .../service/impl/CanvasResolveServiceImpl.java | 33 ++++++ .../impl/ChoiceAnswerResolveServiceImpl.java | 47 ++++++++ .../impl/DiagnoseAnswerResolveServiceImpl.java | 23 ++++ .../service/impl/ExtraResolveStrategyService.java | 1 + .../service/impl/HzllmInteractiveServiceImpl.java | 58 ---------- .../service/impl/HznlmInteractiveServiceImpl.java | 72 +++++++++++++ .../service/impl/HznlmInvokeServiceImpl.java | 120 +++++++++++++++++++++ .../service/impl/InteractiveServiceImpl.java | 3 +- .../service/impl/JumpPageServiceImpl.java | 1 + .../service/impl/JumpRouteJoinStrategy.java | 1 + .../impl/ParamAnswerResolveServiceImpl.java | 23 ++++ .../interactive/service/impl/ParamStrategy.java | 1 + .../service/impl/ParamsServiceImpl.java | 1 + .../impl/RemoteAnswerResolveServiceImpl.java | 23 ++++ .../service/impl/VideoResolveServiceImpl.java | 73 +++++++++++++ .../hzims/bigmodel/interactive/vo/AnswerVO.java | 7 ++ .../bigmodel/interactive/vo/ResolveResultVO.java | 29 +++++ .../bigmodel/manager/SessionRedisManager.java | 28 +++++ .../hzims/bigmodel/utils/RequestClientUtil.java | 48 +++++++++ 31 files changed, 780 insertions(+), 97 deletions(-) delete mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java deleted file mode 100644 index 4005c37..0000000 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.constants; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/04/26 13:29 - */ -public interface FunctionConstants { - - @AllArgsConstructor - enum TypeEnum { - /**跳转页面**/ - JUMP("1"), - /**链接**/ - LINK("2"), - /**参数**/ - PARAMS("3"), - /**选项**/ - CHOOSE("4"), - /**确认**/ - CONFIRM("5"), - CHART("6"); - ; - @Getter - private String type; - - public static TypeEnum getTypeEnumByType (String type) { - Optional typeEnumOptional = Arrays.stream(TypeEnum.class.getEnumConstants()).filter(e -> type.equals(e.getType())).findFirst(); - return typeEnumOptional.orElse(null); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java new file mode 100644 index 0000000..4005c37 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/04/26 13:29 + */ +public interface FunctionConstants { + + @AllArgsConstructor + enum TypeEnum { + /**跳转页面**/ + JUMP("1"), + /**链接**/ + LINK("2"), + /**参数**/ + PARAMS("3"), + /**选项**/ + CHOOSE("4"), + /**确认**/ + CONFIRM("5"), + CHART("6"); + ; + @Getter + private String type; + + public static TypeEnum getTypeEnumByType (String type) { + Optional typeEnumOptional = Arrays.stream(TypeEnum.class.getEnumConstants()).filter(e -> type.equals(e.getType())).findFirst(); + return typeEnumOptional.orElse(null); + } + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java new file mode 100644 index 0000000..6663556 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/InfoMessageConstant.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:35 + */ +public interface InfoMessageConstant { + + String ERROR_MESSAGE = "非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java new file mode 100644 index 0000000..27a8978 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.bigmodel.interactive.factory; + +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:44 + */ +public class AnswerResolveFactory { + + public static final String DIAGNOSE_ANSWER_SERVICE = "diagnoseAnswerResolveService"; + public static final String CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService"; + public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService"; + public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService"; + + public static IResolveService getResolveService(String funcCode) { + FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); + if(Func.isNotEmpty(funcRouteEnum)) { + switch (funcRouteEnum) { + case DIAGNOSE: + return SpringUtil.getBean(DIAGNOSE_ANSWER_SERVICE); + case CHOOSE_VIDEO: + case CHOOSE_CANVAS: + case CHOOSE_STATION: + case CHOOSE_FAULT: + case CHOOSE_YC: + case CHOOSE_YK: + return SpringUtil.getBean(CHOICE_ANSWER_SERVICE); + case CONFIRM_YK: + return SpringUtil.getBean(REMOTE_ANSWER_SERVICE); + case SHOW_PARAM: + return SpringUtil.getBean(PARAM_ANSWER_SERVICE); + default: + throw new ServiceException("service解析失败!"); + } + } + throw new ServiceException("service解析失败!"); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java new file mode 100644 index 0000000..b3fafc6 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java @@ -0,0 +1,44 @@ +package com.hnac.hzims.bigmodel.interactive.factory; + +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:53 + */ +public class ResolveFactory { + + public static final String CANVAS_RESOLVE_SERVICE = "canvasResolveService"; + public static final String VIDEO_RESOLVE_SERVICE = "videoResolveService"; + + /** + * 获取解析函数需要的service + * @param funcCode 函数编号 + * @return 解析函数所需service + */ + public static IResolveService getResolveService(String funcCode) { + BladeLogger logger = SpringUtil.getBean(BladeLogger.class); + FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); + if(Func.isNotEmpty(funcRouteEnum)) { + switch(funcRouteEnum) { + case OPEN_CANVAS: + return SpringUtil.getBean("canvasResolveService"); + case OPEN_VIDEO: + return SpringUtil.getBean("videoResolveService"); + default: + logger.error("hzims:bigModel:getResolveService","函数解析失败,函数编号为:" + funcCode); + throw new ServiceException("service解析失败"); + } + } + throw new ServiceException("service解析失败"); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java new file mode 100644 index 0000000..49608bb --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; + +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:39 + */ +public interface IAnswerResolveService { + + AnswerVO resolve(AnswerVO answer); + + default Stream extraStream(AnswerVO answer) { + return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java index f134480..6239980 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java @@ -1,7 +1,9 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import org.springframework.web.bind.annotation.RequestBody; import javax.validation.Valid; @@ -15,4 +17,5 @@ public interface IHznlmInteractiveService { List getAuthData(@RequestBody @Valid AuthDataDTO req); + ResolveResultVO resolve(ModelFunctionReq req); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java new file mode 100644 index 0000000..6cfa306 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java @@ -0,0 +1,63 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import org.springblade.core.tool.api.R; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:20 + */ +public interface IHznlmInvokeService { + + /** + * 基础问题 + * @param question 提问问题 + * @param sessionId 会话ID + * @param userId 提问人ID + * @return 提问结果 + */ + void ask(String question, String sessionId, String userId); + + /** + * 特殊问题 + * @param sessionId 会话ID + * @param userId 提问人ID + * @param extra 特殊问题内容 + * @return 提问结果 + */ + void specialAsk(String sessionId, String userId, Map extra); + + /** + * 知识库问题 + * @param question 问题名称 + * @param sessionId 会话ID + * @param userId 提问人ID + * @param knowledge 知识库名称 + */ + void knowledgeAsk(String question, String sessionId, String userId, String knowledge); + + /** + * 删除对话记录 + * @param sessionId 会话ID + */ + void removeSessionId(String sessionId); + + /** + * 获取热点问题 + * @return 热点问题 + */ + List hotQuestions(); + + /** + * 查询问答状态 + * @param sessionIds 会话ID,按逗号分隔 + * @return 答案列表 + */ + List getAnswerBySessionIds(String sessionIds); + + + +} 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 9474795..e35541b 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 @@ -13,6 +13,7 @@ import java.util.Map; * @Author: huangxing * @Date: 2024/04/26 14:51 */ +@Deprecated public interface IInteractiveService { ExtraVO resolveStations(String startTime, String endTime, String type, String enumType); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java index fa4f9d5..5a24baa 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java @@ -9,6 +9,7 @@ import java.util.Map; * @Author: huangxing * @Date: 2024/04/26 11:46 */ +@Deprecated public interface IJumpPageService { String dealJumpTypeFunction(FunctionEntity function, Map args); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java index aee914a..f39a0fb 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java @@ -8,6 +8,7 @@ import java.util.Map; * @Author: huangxing * @Date: 2024/05/09 08:50 */ +@Deprecated public interface IParamsService { String dealJumpTypeFunction(FunctionEntity function, Map args); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java new file mode 100644 index 0000000..97c6aa4 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.bigmodel.interactive.service; + +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:39 + */ +public interface IResolveService { + + ExtraVO resolve(Long id); + + ResolveResultVO resolve(ModelFunctionReq req); + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java new file mode 100644 index 0000000..4ae5cd5 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; +import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/21 15:39 + */ +@Service(ResolveFactory.CANVAS_RESOLVE_SERVICE) +@AllArgsConstructor +@Slf4j +public class CanvasResolveServiceImpl implements IResolveService { + + private final ScadaClient scadaClient; + + @Override + public ResolveResultVO resolve(ModelFunctionReq req) { + return null; + } + + @Override + public ExtraVO resolve(Long id) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java new file mode 100644 index 0000000..7b27572 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +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 groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + * @Describe 选项答案解析服务层 + */ +@AllArgsConstructor +@Service(AnswerResolveFactory.CHOICE_ANSWER_SERVICE) +@Slf4j +public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + List extraList = this.extraStream(answer).map(this::getExtra).collect(Collectors.toList()); + answer.setExtras(extraList.toArray()); + + return answer; + } + + private ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = new ExtraVO(); + JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); + result.setSelection(selections); + result.setSpecial(true); + String funcCode = originExtra.getString("func"); + result.setFuncCode(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + return result; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java new file mode 100644 index 0000000..984247a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +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 groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:59 + */ +@Service(AnswerResolveFactory.DIAGNOSE_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 2a59476..1dc967a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -36,6 +36,7 @@ import java.util.stream.Collectors; */ @Service @AllArgsConstructor +@Deprecated public class ExtraResolveStrategyService { public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java deleted file mode 100644 index 668bd66..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HzllmInteractiveServiceImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum; -import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; -import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; -import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; -import groovy.util.logging.Slf4j; -import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.Func; -import org.springblade.system.dto.DeptStationDTO; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/06/21 10:24 - */ -@Service -@AllArgsConstructor -@Slf4j -public class HzllmInteractiveServiceImpl implements IHznlmInteractiveService { - - private final AuthenticationService authenticationService; - - @Override - public List getAuthData(AuthDataDTO req) { - DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType()); - switch(authTypeEnum) { - case STATION: - return this.getStationAuthData(req.getUserId()); - case DEPT: - return this.getDeptAuthData(req.getUserId()); - default: - throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持"); - } - } - - public List getDeptAuthData(String userId) { - List deptStationDTOs = authenticationService.getStationPermissionsById(userId); - return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); - } - - public List getStationAuthData(String userId) { - List deptStationDTOs = authenticationService.getStationPermissionsById(userId); - return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getId())).collect(Collectors.toList()); - } - - private AuthDataVO convertStationAuthData(DeptStationDTO req) { - return new AuthDataVO(req.getStationId(),req.getDeptName()); - } - - private AuthDataVO convertDeptAuthData(DeptStationDTO req) { - return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName()); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java new file mode 100644 index 0000000..2ccc41f --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum; +import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.dto.DeptStationDTO; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/06/21 10:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { + + private final AuthenticationService authenticationService; + + @Override + public List getAuthData(AuthDataDTO req) { + DataAuthTypeEnum authTypeEnum = DataAuthTypeEnum.getEnumByType(req.getType()); + switch(authTypeEnum) { + case STATION: + return this.getStationAuthData(req.getUserId()); + case DEPT: + return this.getDeptAuthData(req.getUserId()); + default: + throw new ServiceException(req.getType() + "改类型获取权限数据暂不支持"); + } + } + + @Override + public ResolveResultVO resolve(ModelFunctionReq req) { + IResolveService resolveService = ResolveFactory.getResolveService(req.getFunctionName()); + try { + return resolveService.resolve(req); + } catch (Exception e) { + return ResolveResultVO.error(); + } + } + + public List getDeptAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); + } + + public List getStationAuthData(String userId) { + List deptStationDTOs = authenticationService.getStationPermissionsById(userId); + return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getId())).collect(Collectors.toList()); + } + + private AuthDataVO convertStationAuthData(DeptStationDTO req) { + return new AuthDataVO(req.getStationId(),req.getDeptName()); + } + + private AuthDataVO convertDeptAuthData(DeptStationDTO req) { + return new AuthDataVO(String.valueOf(req.getDeptId()),req.getDeptName()); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java new file mode 100644 index 0000000..34445c7 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -0,0 +1,120 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.manager.SessionRedisManager; +import com.hnac.hzims.bigmodel.utils.RequestClientUtil; +import com.xxl.job.core.log.XxlJobLogger; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +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.dto.DeptStationDTO; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:20 + * @Describe HZN_LM大模型接口调用服务层 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class HznlmInvokeServiceImpl implements IHznlmInvokeService { + + private final AuthenticationService authenticationService; + private final BigModelInvokeUrl bigModelInvokeUrl; + private final BladeLogger logger; + private final SessionRedisManager sessionRedisManager; + + @Value("${fdp.host}") + private String fdpHost; + + @Override + public void ask(String question, String sessionId, String userId) { + Map params = new HashMap<>(); + params.put("id",sessionId); + params.put("userid", userId); + params.put("query",question); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void specialAsk(String sessionId, String userId, Map extra) { + Map params = new HashMap<>(); + params.put("id",sessionId); + params.put("userid", userId); + params.put("extra",extra); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { + Map params = new HashMap<>(); + params.put("id", sessionId); + params.put("userid", userId); + params.put("query", question); + params.put("knowledge", knowledge); + Map authDataIds = this.getAuthDataIds(userId); + params.putAll(authDataIds); + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), params); + sessionRedisManager.addSessionId(sessionId); + } + + @Override + public void removeSessionId(String sessionId) { + Map params = new HashMap<>(); + params.put("id",sessionId); + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params); + sessionRedisManager.removeSessionId(sessionId); + } + + @Override + public List hotQuestions() { + return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getHotQuestion(), null, List.class); + } + + @Override + public List getAnswerBySessionIds(String sessionIds) { + Map params = new HashMap<>(); + params.put("ids",Func.toStrList(",",sessionIds).toArray()); + List answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, List.class); + //TODO 解析答案 + return answerVOList; + } + + private Map getAuthDataIds(String userId) { + List authDatas = authenticationService.getStationPermissionsById(userId); + Map result = new HashMap<>(2); + String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId) + .filter(StringUtil::isNotBlank).toArray(String[]::new); + String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId) + .filter(Func::isNotEmpty).toArray(String[]::new); + result.put("stationids", stationIds); + result.put("projectids", projectIds); + return result; + } +} 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 d670ef6..d5e1e6e 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 @@ -70,6 +70,7 @@ import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMO @Service @Slf4j @RequiredArgsConstructor +@Deprecated public class InteractiveServiceImpl implements IInteractiveService { private final BladeLogger logger; @@ -216,7 +217,7 @@ public class InteractiveServiceImpl implements IInteractiveService { log.error("远程调用大模型接口" + url + "失败!"); throw new ServiceException("远程调用大模型接口" + url + "失败!"); }); - return JSONObject.parseObject(response.body(),resultT); + return JSONObject.parseObject(response.body(), resultT); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java index b5012db..71bcc88 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java @@ -26,6 +26,7 @@ import java.util.Set; @Service @AllArgsConstructor @Slf4j +@Deprecated public class JumpPageServiceImpl implements IJumpPageService { private final IFuncParamService paramService; 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 ddb6f69..b5b6b5f 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 @@ -25,6 +25,7 @@ import java.util.stream.IntStream; */ @Component @RequiredArgsConstructor +@Deprecated public class JumpRouteJoinStrategy { private final IStationClient stationClient; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java new file mode 100644 index 0000000..e982d7f --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +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 groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + */ +@Service(AnswerResolveFactory.PARAM_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index e84f616..67e49a0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -23,6 +23,7 @@ import java.util.Map; @Component @Slf4j @AllArgsConstructor +@Deprecated public class ParamStrategy { private final IStationVideoTypeClient videoClient; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java index dd462c6..7d134e1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java @@ -22,6 +22,7 @@ import java.util.Optional; @Service @Slf4j @AllArgsConstructor +@Deprecated public class ParamsServiceImpl implements IParamsService { private final ParamStrategy strategy; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java new file mode 100644 index 0000000..9ba5e42 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +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 groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/21 19:02 + */ +@Service(AnswerResolveFactory.REMOTE_ANSWER_SERVICE) +@Slf4j +@AllArgsConstructor +public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { + + @Override + public AnswerVO resolve(AnswerVO answer) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java new file mode 100644 index 0000000..3cdc225 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java @@ -0,0 +1,73 @@ +package com.hnac.hzims.bigmodel.interactive.service.impl; + +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:17 + */ +@Service(ResolveFactory.VIDEO_RESOLVE_SERVICE) +@AllArgsConstructor +@Slf4j +public class VideoResolveServiceImpl implements IResolveService { + + private final IStationVideoTypeClient videoClient; + private final BladeLogger logger; + + @Override + public ResolveResultVO resolve(ModelFunctionReq req) { + Map args = req.getFunctionArgs(); + String id = args.get("id"); + String name = args.get("name"); + Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { + logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req)); + throw new ServiceException("解析传参错误,缺少必要参数video_id"); + }); + ExtraVO extra = this.resolve(Long.valueOf(id)); + String message = "已成功打开" + name + ";"; + return new ResolveResultVO(message,extra); + } + + @Override + public ExtraVO resolve(Long id) { + // 跳转页面逻辑 + ExtraVO extraVO = new ExtraVO(); + R videoR = videoClient.getById(Long.valueOf(id)); + if(videoR.isSuccess()) { + StationVideoTypeEntity video = videoR.getData(); + extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + extraVO.setImmediatelyJump(true); + extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); + Map params = new HashMap<>(); + params.put("name", video.getName()); + params.put("videoHost", video.getVideoHost()); + params.put("pointCode", video.getPointCode()); + params.put("appKey", video.getAppKey()); + params.put("appSecret", video.getAppSecret()); + params.put("liveSourceAddress",video.getLiveSourceAddress()); + extraVO.setParams(params); + } + return extraVO; + } +} 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 29baf54..e4b9e1c 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 @@ -1,8 +1,10 @@ package com.hnac.hzims.bigmodel.interactive.vo; import com.alibaba.fastjson.annotation.JSONField; +import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tool.utils.BeanUtil; @@ -16,6 +18,7 @@ import java.io.Serializable; @Data @ApiModel("HZLLM答案VO对象") @EqualsAndHashCode +@AllArgsConstructor public class AnswerVO implements Serializable { @ApiModelProperty("发起问答时的随机ID") @@ -56,6 +59,10 @@ public class AnswerVO implements Serializable { @JSONField(name = "voice_answer") private String[] voiceAnswer; + public static AnswerVO error(String sessionId,String userId,String query) { + 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); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java new file mode 100644 index 0000000..f24b67e --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ResolveResultVO.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.hnac.hzims.bigmodel.interactive.constants.InfoMessageConstant; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/06/21 16:31 + */ +@EqualsAndHashCode +@Data +@AllArgsConstructor +@ApiModel(value = "解析结果",description = "解析结果") +public class ResolveResultVO implements Serializable { + + private String content; + + private ExtraVO extraVO; + + public static ResolveResultVO error() { + return new ResolveResultVO(InfoMessageConstant.ERROR_MESSAGE,null); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java new file mode 100644 index 0000000..decbf60 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.manager; + +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; + +/** + * @Author: huangxing + * @Date: 2024/06/21 18:23 + */ +@Component +public class SessionRedisManager { + + @Autowired + private RedisTemplate redisTemplate; + + public void addSessionId(String sessionId) { + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); + } + + public void removeSessionId(String sessionId) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java new file mode 100644 index 0000000..d49dc3c --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.bigmodel.utils; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import groovy.util.logging.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.util.Assert; + +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/21 17:12 + */ +public class RequestClientUtil { + + /** + * 无返回结果远程调用http接口 + * @param url 接口url + * @param body 传参body + */ + public static void postCall(String url, Map body) { + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new ServiceException("远程调用大模型接口" + url + "失败!"); + }); + } + + /** + * 远程调用http接口 + * @param url 接口url + * @param body 传参 + * @param resultT 结果解析对象 + * @return 结果 + * @param 结果解析对象类型 + */ + public static T postCall(String url, Map body, Class resultT) { + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new ServiceException("远程调用大模型接口" + url + "失败!"); + }); + return JSONObject.parseObject(response.body(), resultT); + } + +} From 3acfb76154b055f9a6af32a148c928949510d6fc Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 26 Jun 2024 09:03:18 +0800 Subject: [PATCH 127/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9E=B6=E6=9E=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/data/controller/RemoteController.java | 37 +++++++++ .../bigmodel/data/service/HistoryDataService.java | 97 ++++++++++++++++++++++ .../hzims/bigmodel/data/service/RemoteService.java | 31 +++++++ .../controller/AnalyseDataController.java | 1 - .../controller/FontEndInteractiveController.java | 55 ++++++++++++ .../controller/HznlmInteractiveController.java | 13 ++- .../controller/InteractiveController.java | 3 + .../interactive/factory/AnswerResolveFactory.java | 10 ++- .../interactive/service/IAnswerResolveService.java | 14 +++- .../service/impl/AnalyseDataServiceImpl.java | 71 +--------------- .../impl/ChoiceAnswerResolveServiceImpl.java | 8 +- .../impl/DiagnoseAnswerResolveServiceImpl.java | 29 ++++++- .../service/impl/ExtraResolveStrategyService.java | 8 +- .../service/impl/HznlmInvokeServiceImpl.java | 15 +++- .../impl/ParamAnswerResolveServiceImpl.java | 87 ++++++++++++++++++- .../impl/RemoteAnswerResolveServiceImpl.java | 38 ++++++++- .../hzims/bigmodel/interactive/vo/AnswerVO.java | 2 + .../bigmodel/manager/SessionRedisManager.java | 6 ++ .../schedule/FrontEndInteractiveSchedule.java | 85 +++++++++++++++++++ .../bigmodel/schedule/InteractiveSchedule.java | 25 +----- .../hzims/bigmodel/utils/RequestClientUtil.java | 5 +- .../bigmodel/websocket/config/WebSocketConfig.java | 2 +- .../websocket/service/InteractiveWsService.java | 10 ++- 23 files changed, 530 insertions(+), 122 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java new file mode 100644 index 0000000..c420ba7 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.bigmodel.data.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.data.service.RemoteService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:42 + */ +@AllArgsConstructor +@RequestMapping("/remote") +@RestController +@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") +@Business(module = BigModelConstants.APP_NAME,value = "数据平台遥控指令管理") +public class RemoteController { + + private final RemoteService remoteService; + + @ApiOperation("下发遥控指令") + @ApiOperationSupport(order = 1) + @PostMapping("/sendRemoteControl") + public R sendRemoteControl(ControlDTO controlDTO) { + return remoteService.sendRemoteControl(controlDTO); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java new file mode 100644 index 0000000..4a3fc76 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java @@ -0,0 +1,97 @@ +package com.hnac.hzims.bigmodel.data.service; + +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; +import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; +import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:57 + */ +@Service +@Slf4j +@AllArgsConstructor +public class HistoryDataService { + + private final DeviceDataClient deviceDataClient; + private final BladeLogger logger; + public static final int DATA_COUNT_MAX = 8000; + + public Result getPolymerizationData(HistoryDataSearchVO searchVO) { + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { + throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); + }); + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + ReductionDataDTO dataDTO = new ReductionDataDTO(); + ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); + reductionAttrData.setSignage(searchVO.getSignage()); + reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); + reductionAttrData.setKeepFigures(2); + dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); + dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); + dataDTO.setDeviceCode(searchVO.getDeviceCode()); + dataDTO.setNeedPage(false); + dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); + dataDTO.setTimeInterval(1); + dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); + logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); + return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); + } + + public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { + LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); + LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); + Duration duration = Duration.between(start, end); + int count; + switch(dateEnum) { + case YEAR: + count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case MONTH: + count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case DAY: + count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case HOUR: + count = Long.valueOf(duration.toHours()).intValue(); + break; + case MINUTE: + count = Long.valueOf(duration.toMinutes()).intValue(); + break; + case SECOND: + count = Long.valueOf(duration.getSeconds()).intValue(); + break; + default: + throw new ServiceException("未找到相关时间类型,查询失败!"); + } + if(count <= DATA_COUNT_MAX) { + return dateEnum; + } + else { + return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); + } + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java new file mode 100644 index 0000000..551a10b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.bigmodel.data.service; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springblade.system.feign.IRemoteClient; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:36 + * @Descirbe: 数据平台 - 遥控服务类 + */ +@Service +@Slf4j +@AllArgsConstructor +public class RemoteService { + + private final IRemoteClient remoteClient; + + /** + * 发送遥控指令 + * @param controlDTO 遥控指令 + * @return 结果 + */ + public R sendRemoteControl(ControlDTO controlDTO) { + return remoteClient.sendCtrl(controlDTO); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java index 63c6750..5ecf019 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java @@ -1,6 +1,5 @@ package com.hnac.hzims.bigmodel.interactive.controller; -import com.alibaba.fastjson.JSONObject; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java new file mode 100644 index 0000000..8ec9e8a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java @@ -0,0 +1,55 @@ +package com.hnac.hzims.bigmodel.interactive.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:19 + */ +@RestController +@RequestMapping("/fontEnd/interactive") +@Api(value = "前端交互控制层",tags = "前端交互控制层") +@AllArgsConstructor +@Business(module = BigModelConstants.APP_NAME,value = "前端交互层管理",ignore = false) +public class FontEndInteractiveController { + + private final IHznlmInvokeService hznlmInvokeService; + + @ApiOperation("提问") + @ApiOperationSupport(order = 1) + @GetMapping("/ask") + public R ask(@RequestParam @ApiParam("用户提出问题") String question, @RequestParam @ApiParam("问答sessionId") String sessionId, @RequestParam @ApiParam("用户Id") String userId) { + hznlmInvokeService.ask(question, sessionId, userId); + return R.success("操作成功!"); + } + + @ApiOperation("删除对话sessionId") + @ApiOperationSupport(order = 2) + @GetMapping("/removeSessionId") + public R removeSessionId(@RequestParam(value = "id") String sessionId) { + hznlmInvokeService.removeSessionId(sessionId); + return R.success("操作成功!"); + } + + @ApiOperation("获取热点问题") + @ApiOperationSupport(order = 3) + @GetMapping("/hotQuestions") + public R> hotQuestions() { + return R.data(hznlmInvokeService.hotQuestions()); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 2b125a9..3924173 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -3,17 +3,16 @@ package com.hnac.hzims.bigmodel.interactive.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; @@ -38,4 +37,10 @@ public class HznlmInteractiveController { return R.data(interactiveService.getAuthData(req)); } + @ApiOperation("解析大模型函数") + @ApiOperationSupport(order = 2) + @PostMapping("/resolve") + public R resolve(@RequestBody @Valid ModelFunctionReq req) { + return R.data(interactiveService.resolve(req)); + } } 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 7305f78..ca90465 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 @@ -42,6 +42,7 @@ public class InteractiveController { @ApiOperation("提问") @ApiOperationSupport(order = 2) @GetMapping("/ask") + @Deprecated public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) { return interactiveService.ask(question, sessionId, userId); } @@ -67,6 +68,7 @@ public class InteractiveController { @ApiOperation("删除对话sessionId") @ApiOperationSupport(order = 5) @GetMapping("/removeSessionId") + @Deprecated public R removeSessionId(@RequestParam(value = "id") String sessionId) { return R.data(interactiveService.removeSessionId(sessionId)); } @@ -99,6 +101,7 @@ public class InteractiveController { @ApiOperation("获取热点问题") @ApiOperationSupport(order = 8) @GetMapping("/hotQuestions") + @Deprecated public R hotQuestions() { try{ List questions = interactiveService.hotQuestions(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java index 27a8978..9595974 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java @@ -1,6 +1,9 @@ package com.hnac.hzims.bigmodel.interactive.factory; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import org.springblade.core.log.exception.ServiceException; @@ -19,7 +22,12 @@ public class AnswerResolveFactory { public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService"; public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService"; - public static IResolveService getResolveService(String funcCode) { + public static IAnswerResolveService getResolveService(Object extra) { + String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func"); + return AnswerResolveFactory.getResolveService(funcCode); + } + + public static IAnswerResolveService getResolveService(String funcCode) { FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); if(Func.isNotEmpty(funcRouteEnum)) { switch (funcRouteEnum) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java index 49608bb..4800164 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IAnswerResolveService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import java.util.Arrays; import java.util.stream.Stream; @@ -15,8 +16,19 @@ public interface IAnswerResolveService { AnswerVO resolve(AnswerVO answer); + /** + * 解析 extra + * @param originExtra 大模型传入 extra + * @return 解析后的 extra + */ + ExtraVO getExtra(JSONObject originExtra); + + /*** + * + * @param answer + * @return + */ default Stream extraStream(AnswerVO answer) { return Arrays.stream(answer.getExtras()).map(JSON::toJSONString).map(JSONObject::parseObject); } - } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 1d574b1..9ff9828 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -1,14 +1,12 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.data.service.HistoryDataService; import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; import com.hnac.hzinfo.sdk.core.response.Result; @@ -28,7 +26,6 @@ import org.springframework.util.Assert; import java.time.Duration; import java.time.LocalDateTime; -import java.time.Period; import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.List; @@ -43,9 +40,7 @@ import java.util.stream.Collectors; @AllArgsConstructor public class AnalyseDataServiceImpl implements IAnalyseDataService { - private final DeviceDataClient deviceDataClient; - private final BladeLogger logger; - public static final int DATA_COUNT_MAX = 8000; + private final HistoryDataService historyDataService; @Override public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { @@ -57,14 +52,14 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); searchVO.setDataType(dateEnum.getDateType()); // 获取最适配时间段 - DateEnum adapterDate = this.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); + DateEnum adapterDate = historyDataService.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)"; searchVO.setDataType(adapterDate.getDateType()); ExtraVO extraVO = new ExtraVO(); extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); Map params = new HashMap<>(1); - Result reductionDataVOR = this.getPolymerizationData(searchVO); + Result reductionDataVOR = historyDataService.getPolymerizationData(searchVO); String label; if(!reductionDataVOR.isSuccess()) { params.put("errorInfo",reductionDataVOR.getMsg()); @@ -102,62 +97,4 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { extraVO.setParams(params); return extraVO; } - - private Result getPolymerizationData(HistoryDataSearchVO searchVO) { - DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); - Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { - throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); - }); - // 聚合数据方式处理 - DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); - ReductionDataDTO dataDTO = new ReductionDataDTO(); - ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); - reductionAttrData.setSignage(searchVO.getSignage()); - reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); - reductionAttrData.setKeepFigures(2); - dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(),DateUtil.DATETIME_FORMATTER)); - dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); - dataDTO.setDeviceCode(searchVO.getDeviceCode()); - dataDTO.setNeedPage(false); - dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); - dataDTO.setTimeInterval(1); - dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); - logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); - return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); - } - - private DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { - LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); - LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); - Duration duration = Duration.between(start, end); - int count; - switch(dateEnum) { - case YEAR: - count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case MONTH: - count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case DAY: - count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case HOUR: - count = Long.valueOf(duration.toHours()).intValue(); - break; - case MINUTE: - count = Long.valueOf(duration.toMinutes()).intValue(); - break; - case SECOND: - count = Long.valueOf(duration.getSeconds()).intValue(); - break; - default: - throw new ServiceException("未找到相关时间类型,查询失败!"); - } - if(count <= DATA_COUNT_MAX) { - return dateEnum; - } - else { - return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); - } - } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java index 7b27572..47bb78a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -28,13 +28,13 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { @Override public AnswerVO resolve(AnswerVO answer) { - List extraList = this.extraStream(answer).map(this::getExtra).collect(Collectors.toList()); - answer.setExtras(extraList.toArray()); - + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); return answer; } - private ExtraVO getExtra(JSONObject originExtra) { + @Override + public ExtraVO getExtra(JSONObject originExtra) { ExtraVO result = new ExtraVO(); JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); result.setSelection(selections); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java index 984247a..b0dcc7f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java @@ -1,12 +1,20 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; 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 groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.Map; + /** * @Author: huangxing * @Date: 2024/06/21 18:59 @@ -18,6 +26,25 @@ public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { @Override public AnswerVO resolve(AnswerVO answer) { - return null; + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data"))); + Map params = new HashMap<>(5); + params.put("faultId",data.getString("fault_id")); + params.put("name",data.getString("fault_name")); + params.put("station",data.getString("station_id")); + params.put("fdpDeviceName",data.getString("device_name")); + params.put("fdpOrd",data.getString("ord")); + result.setParams(params); + String funcCode = originExtra.getString("func"); + result.setFuncCode(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + return result; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 1dc967a..40e7b0d 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -8,22 +8,15 @@ import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; import com.hnac.hzims.bigmodel.interactive.vo.*; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; -import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; -import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; -import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; -import org.springblade.system.dto.ControlDTO; -import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.time.format.DateTimeFormatter; @@ -147,6 +140,7 @@ public class ExtraResolveStrategyService { return result; } + @Deprecated private ExtraVO resolveConfirmRemote(Map extra) { ExtraVO result = new ExtraVO(); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index 34445c7..a09ffa0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -4,15 +4,17 @@ import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.TypeReference; +import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.manager.SessionRedisManager; import com.hnac.hzims.bigmodel.utils.RequestClientUtil; import com.xxl.job.core.log.XxlJobLogger; -import groovy.util.logging.Slf4j; 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.tool.api.R; @@ -94,15 +96,20 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public List hotQuestions() { - return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getHotQuestion(), null, List.class); + try { + return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getHotQuestion(), null, new TypeReference>(){}); + } + catch (Exception e) { + log.error("An error occurred",e); + return Lists.newArrayList(); + } } @Override public List getAnswerBySessionIds(String sessionIds) { Map params = new HashMap<>(); params.put("ids",Func.toStrList(",",sessionIds).toArray()); - List answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, List.class); - //TODO 解析答案 + List answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference>(){}); return answerVOList; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java index e982d7f..507b306 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java @@ -1,11 +1,26 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; +import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.*; +import com.xxl.job.core.log.XxlJobLogger; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * @Author: huangxing @@ -16,8 +31,76 @@ import org.springframework.stereotype.Service; @AllArgsConstructor public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { + private final IAnalyseDataService analyseDataService; + + public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; + @Override public AnswerVO resolve(AnswerVO answer) { - return null; + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + DataVO data = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")),DataVO.class); + Assert.isTrue(Func.isNotEmpty(data),() -> { + XxlJobLogger.log("解析参数答案失败,extra不能为空!"); + throw new ServiceException("解析参数答案失败,extra不能为空!"); + }); + if(Func.isNotEmpty(data.getReal())) { + // 处理查询实时数据 + RealDataVO real = data.getReal(); + Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); + real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + } + else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) { + // 处理查询历史数据 + this.getHistoryData(data); + } + String funcCode = originExtra.getString("func"); + ExtraVO result = new ExtraVO(); + result.setFuncCode(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + Map param = new HashMap(1); + param.put("data", data); + result.setParams(param); + return result; } + + /** + * 查询历史数据 + * @param data 大模型识别数据信息 + * @return 历史数据 + */ + private ExtraVO getHistoryData(DataVO data) { + // 确认查询聚合方式传入 + Assert.isTrue(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod()),() -> { + XxlJobLogger.log("历史数据查询方式为空,查询失败!"); + throw new ServiceException("历史数据查询方式为空,查询失败!"); + }); + return analyseDataService.getHistoryData(this.convertHistoryDataSearch(data)); + } + + /** + * 获取历史数据查询对象 + * @param data 大模型解析点位信息 + * @return 历史数据查询对象 + */ + private HistoryDataSearchVO convertHistoryDataSearch(DataVO data) { + HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); + DataItemVO item = data.getItem(); + searchVO.setDataType(data.getDataType()); + searchVO.setAttrName(item.getAttrName()); + searchVO.setDeviceCode(item.getDeviceId()); + searchVO.setDeviceName(item.getDeviceName()); + searchVO.setStationName(item.getProjectName()); + searchVO.setMethod(data.getMethod()); + searchVO.setSignage(item.getSignage()); + searchVO.setStartTime(data.getStartTime()); + searchVO.setEndTime(data.getEndTime()); + return searchVO; + } + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java index 9ba5e42..95f271a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java @@ -1,12 +1,24 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; 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 com.hnac.hzims.bigmodel.interactive.vo.RemoteParamVO; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.Map; + /** * @Author: huangxing * @Date: 2024/06/21 19:02 @@ -16,8 +28,32 @@ import org.springframework.stereotype.Service; @AllArgsConstructor public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { + private final DeviceClient deviceClient; + @Override public AnswerVO resolve(AnswerVO answer) { - return null; + Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); + answer.setExtras(extraArray); + return answer; + } + + @Override + public ExtraVO getExtra(JSONObject originExtra) { + ExtraVO result = new ExtraVO(); + RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class); + String funcCode = originExtra.getString("func"); + result.setFuncCode(funcCode); + result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); + if(funcVOR.isSuccess()) { + Map param = new HashMap(); + param.put("control",funcVOR.getData()); + param.put("deviceName",remoteParam.getDeviceName()); + param.put("projectName",remoteParam.getProjectName()); + param.put("deviceCode",remoteParam.getDeviceId()); + param.put("value",remoteParam.getValue()); + result.setParams(param); + } + return result; } } 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 e4b9e1c..b42e0a3 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 @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; import org.springblade.core.tool.utils.BeanUtil; import java.io.Serializable; @@ -19,6 +20,7 @@ import java.io.Serializable; @ApiModel("HZLLM答案VO对象") @EqualsAndHashCode @AllArgsConstructor +@NoArgsConstructor public class AnswerVO implements Serializable { @ApiModelProperty("发起问答时的随机ID") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java index decbf60..43c7af3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/manager/SessionRedisManager.java @@ -1,10 +1,13 @@ package com.hnac.hzims.bigmodel.manager; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; +import java.util.List; + import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; /** @@ -25,4 +28,7 @@ public class SessionRedisManager { redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); } + public List getSessionIds() { + return redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java new file mode 100644 index 0000000..cb70eb0 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java @@ -0,0 +1,85 @@ +package com.hnac.hzims.bigmodel.schedule; + +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.service.IHznlmInteractiveService; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.manager.SessionRedisManager; +import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; +import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.xxl.job.core.log.XxlJobLogger; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Component; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.stream.Collectors; + +import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; + +/** + * @Author: huangxing + * @Date: 2024/06/24 09:53 + */ +@Component +@AllArgsConstructor +@Slf4j +public class FrontEndInteractiveSchedule { + + private final SessionRedisManager sessionRedisManager; + private final InteractiveWsService wsService; + private final ThreadPoolExecutor getAnswerPoolExecutor; + private final IHznlmInvokeService hznlmInvokeService; + private final BladeLogger logger; + + @XxlJob(GET_INTERACTIVE_RESULT) + public ReturnT getInteractiveResult(String params) { + List sessionIds = sessionRedisManager.getSessionIds(); + if(CollectionUtil.isEmpty(sessionIds)){ + XxlJobLogger.log("问题都已经回答完毕!"); + return ReturnT.SUCCESS; + } + List answerList = hznlmInvokeService.getAnswerBySessionIds(String.join(",", sessionIds)); + answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> { + // 如果已经获取到答案 则删除缓存 + if(answerVO.getRunning() == 0) { + logger.info("hzims:bigmodel:getInteractiveResult:answer","获取大模型解析答案:" + JSON.toJSONString(answerVO)); + sessionRedisManager.removeSessionId(answerVO.getSessionId()); + } + 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); + JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); + return answerResolveService.getExtra(extraObject); + }).toArray(); + answerVO.setExtras(resolveExtras); + } + catch(Exception e) { + log.error("An error occurred",e); + AnswerVO.error(answerVO.getSessionId(), answerVO.getUserId(), answerVO.getQuery()); + } + } + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + wsService.sendMessage(answerVO.getSessionId(),message); + }, getAnswerPoolExecutor)); + return ReturnT.SUCCESS; + } +} 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 32c132d..cc5cde6 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 @@ -66,30 +66,7 @@ public class InteractiveSchedule { private final ExtraResolveStrategyService extraResolveStrategyService; -// @XxlJob(GET_INTERACTIVE_RESULT) -// public ReturnT execute(String params) { -// String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT); -// Set keySet = redisTemplate.keys(resultKey + "*"); -// keySet.parallelStream().forEach(key -> { -// // 根据Key获取sessionId -// List keySplits = Func.toStrList(":", key); -// String sessionId = keySplits.get(2); -// // 查询websocket是否存在连接session -// WebSocketSession session = InteractiveSessionManager.get(sessionId); -// if(session == null) { -// return; -// } -// TextMessage message = new TextMessage(JSON.toJSONString(redisTemplate.opsForValue().get(key))); -// Boolean sendResult = wsService.sendMessage(sessionId, message); -// Assert.isTrue(sendResult, () -> { -// throw new ServiceException(key + "推送消息失败,推送消息体为:" + JSON.toJSONString(redisTemplate.opsForValue().get(key))); -// }); -// redisTemplate.delete(key); -// }); -// return ReturnT.SUCCESS; -// } - - @XxlJob(GET_INTERACTIVE_RESULT) + // @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { List sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); if(CollectionUtil.isEmpty(sessionIds)){ diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java index d49dc3c..a878fff 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import groovy.util.logging.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springframework.util.Assert; @@ -37,12 +38,12 @@ public class RequestClientUtil { * @return 结果 * @param 结果解析对象类型 */ - public static T postCall(String url, Map body, Class resultT) { + public static T postCall(String url, Map body, TypeReference typeRef) { HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型接口" + url + "失败!"); }); - return JSONObject.parseObject(response.body(), resultT); + return JSONObject.parseObject(response.body(), typeRef); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java index 04a4405..ed9a2a5 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/config/WebSocketConfig.java @@ -18,7 +18,7 @@ public class WebSocketConfig implements WebSocketConfigurer { @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { - registry.addHandler(interactiveHandler(), "/interactive/{sessionId}").setAllowedOrigins("*"); + registry.addHandler(interactiveHandler(), "/websocket/interactive/{sessionId}").setAllowedOrigins("*"); } @Bean public WebSocketHandler interactiveHandler() { 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 258a376..c02fbab 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 @@ -20,8 +20,14 @@ public class InteractiveWsService implements WebSocketService { @Override public Boolean sendMessage(String sessionId, TextMessage message) { - WebSocketSession session = InteractiveSessionManager.get(sessionId); - return this.sendMessage(session,message); + if(InteractiveSessionManager.SESSION_POOL.containsKey(sessionId)) { + WebSocketSession session = InteractiveSessionManager.get(sessionId); + return this.sendMessage(session,message); + } + else { + log.error("未查询到sessionId,消息推送失败;"); + return false; + } } @Override From ede6fccdc41eb86b6c6d53fcf6e819e164c257f8 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 26 Jun 2024 11:19:19 +0800 Subject: [PATCH 128/151] =?UTF-8?q?#=E5=8F=91=E7=94=B5=E9=87=8F=E6=97=A5?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java | 32 +++++++ .../hnac/hzims/equipment/feign/IEmInfoClient.java | 5 ++ .../hzims/equipment/feign/IEmInfoClientBack.java | 5 ++ .../operational/report/vo/GenerationDeviceVo.java | 24 +++++ .../report/vo/GenerationReportTimeVo.java | 19 ++++ .../operational/report/vo/GenerationReportVo.java | 24 +++++ .../hnac/hzims/equipment/feign/EmInfoClient.java | 6 ++ .../monitor/service/impl/AlarmSaveServiceImpl.java | 2 +- .../alarm/show/controller/ShowAlarmController.java | 10 ++- .../hzims/alarm/show/service/AlarmService.java | 9 +- .../show/service/impl/AlarmHandleServiceImpl.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 30 ++++++- .../controller/GenerationReportController.java | 34 +++++++ .../report/service/IGenerationReportService.java | 14 +++ .../service/impl/GenerationReportServiceImpl.java | 100 +++++++++++++++++++++ 15 files changed, 301 insertions(+), 15 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java new file mode 100644 index 0000000..c58f1f1 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.alarm.show.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; + +/** + * @author ysj + * @date 2023/03/17 10:02:33 + * @version 4.0.0 + */ +@Data +public class AlarmVideoVo { + + @ApiModelProperty("视频设备编码") + private String pointCode; + + @ApiModelProperty("视频名称") + @QueryField(condition = SqlCondition.LIKE) + private String videoName; + + @ApiModelProperty("视频服务器host") + private String videoHost; + + @ApiModelProperty("运管中心appSecret") + private String videoAppSecret; + + @ApiModelProperty("运管中心appKey") + private String videoAppKey; +} + diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 45145c9..b209fd0 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -87,6 +87,8 @@ public interface IEmInfoClient { String RIDE_DEVICES = API_PREFIX + "/rideDevices"; + String CREWS_DEVICES = API_PREFIX + "/crewsDevices"; + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -176,4 +178,7 @@ public interface IEmInfoClient { @GetMapping(RIDE_DEVICES) List rideDevices(@RequestParam("deptIds") List deptIds); + + @GetMapping(CREWS_DEVICES) + List crewsDevices(@RequestParam("refDept") Long refDept); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index 104d494..c84c6eb 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -120,4 +120,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List rideDevices(List longs) { return new ArrayList<>(); } + + @Override + public List crewsDevices(Long refDept) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java new file mode 100644 index 0000000..736f7ce --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationDeviceVo { + + @ApiModelProperty("设备编号") + private String deviceCode; + + @ApiModelProperty("设备名称") + private String deviceName; + + @ApiModelProperty("属性时间范围统计数据") + private List attributes; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java new file mode 100644 index 0000000..1540fae --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportTimeVo { + + @ApiModelProperty("时间") + private String time; + + @ApiModelProperty("值") + private Double value; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java new file mode 100644 index 0000000..13847b5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportVo { + + @ApiModelProperty("属性") + private String attribute; + + @ApiModelProperty("属性名称") + private String attributeName; + + @ApiModelProperty("属性时间范围统计数据") + private List times; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index de29497..adfc78e 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -162,6 +162,12 @@ public class EmInfoClient implements IEmInfoClient { return service.rideDevices(deptIds); } + @Override + @GetMapping(CREWS_DEVICES) + public List crewsDevices(@RequestParam("refDept") Long refDept) { + return service.list(Wrappers.lambdaQuery().eq(EmInfoEntity::getEmType,2).eq(EmInfoEntity::getCreateDept,refDept)); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index ac42e2c..a059740 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -55,7 +55,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); return false; } - // 步骤2.查询当天处理的告警 + // 步骤2.查询1小时内处理的告警 List handlers = handleService.sameDayContent(); // 步骤3.查询延后未完成的告警 List delays = handleService.incompleteContent(); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 162c113..8deca55 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; @@ -54,12 +55,13 @@ public class ShowAlarmController extends BladeController { return R.data(alarmService.counts(alarm)); } - @GetMapping("/getVideosByStationAndRealId") + @GetMapping("/alarmVideos") @ApiOperationSupport(order = 4) @ApiOperation(value = "站点") - public R> getVideosByStationAndRealId(@ApiParam("站点编号") @RequestParam String stationCode, - @ApiParam("监测点ID") @RequestParam String realId) { - return R.data(alarmService.getVideosByStationAndRealId(stationCode,realId)); + public R> alarmVideos(@ApiParam("站点编号") @RequestParam String stationCode, + @ApiParam("设备编号") @RequestParam String deviceCode, + @ApiParam("监测点ID") @RequestParam String realId) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 8b62437..0bc7f77 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -22,11 +23,5 @@ public interface AlarmService extends BaseService { TextMessage majorAlarm(List depts); - /** - * 根据站点、realId 获取视频列表 - * @param stationCode 站点编号 - * @param realId hz3000点位信息 - * @return 视频列表 - */ - List getVideosByStationAndRealId(String stationCode,String realId); + List alarmVideos(String stationCode, String deviceCode, String realId); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 0a954e2..0cbb3a4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -176,7 +176,7 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl sameDayContent() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR_OF_DAY,-1); - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); return this.baseMapper.sameDayContent(start,end); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 1e3838e..f822a0a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -11,6 +11,7 @@ import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; @@ -227,7 +228,8 @@ public class AlarmServiceImpl extends BaseServiceImpl return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); } - @Override + + /* @Override public List getVideosByStationAndRealId(String stationCode, String realId) { R stationR = stationClient.getStationByCode(stationCode); Assert.isTrue(stationR.isSuccess() && Func.isNotEmpty(stationR.getData()), () -> { @@ -254,7 +256,7 @@ public class AlarmServiceImpl extends BaseServiceImpl throw new ServiceException("获取设备绑定视频列表失败!"); }); return videoListR.getData().stream().distinct().collect(Collectors.toList()); - } + }*/ /** * 验证设备编号是否绑定视频 @@ -395,4 +397,28 @@ public class AlarmServiceImpl extends BaseServiceImpl } } } + + /** + * 获取告警视频信息 + * @param stationCode + * @param deviceCode + * @param realId + * @return + */ + @Override + public List alarmVideos(String stationCode, String deviceCode, String realId) { + // 根据realId查找 + if(StringUtil.isNotBlank(realId)){ + + } + // 根据设备编号查找 + if(StringUtil.isNotBlank(deviceCode)){ + + } + // 根据站点编号查找 + if(StringUtil.isNotBlank(stationCode)){ + + } + return new ArrayList<>(); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java new file mode 100644 index 0000000..b462792 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.report.controller; + +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@Slf4j +@AllArgsConstructor +@RestController +@RequestMapping("/generation/report") +public class GenerationReportController extends BladeController { + + private final IGenerationReportService service; + + @GetMapping("/sameDayReport") + public R> sameDayReport(@RequestParam("stationId") String stationId){ + return R.data(service.sameDayReport(stationId)); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java new file mode 100644 index 0000000..ec40e5a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.report.service; + +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; + +import java.util.List; + +/** + * @author ysj + */ +public interface IGenerationReportService { + + List sameDayReport(String stationId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java new file mode 100644 index 0000000..8433cb1 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java @@ -0,0 +1,100 @@ +package com.hnac.hzims.operational.report.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class GenerationReportServiceImpl implements IGenerationReportService { + + private final IStationService stationService; + + private final IEmInfoClient deviceClient; + + /** + * 当天报表 + * @param stationId + * @return + */ + @Override + public List sameDayReport(String stationId) { + // 查询站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getCode,stationId)); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到站点信息!"); + } + // 查询站点机组设备 + List devices = deviceClient.crewsDevices(station.getRefDept()); + if(CollectionUtil.isEmpty(devices)){ + throw new ServiceException("未查询到站点机组类型设备!"); + } + // FIXME 属性标识 + Map signages = new HashMap<>(); + signages.put("active_power","有功功率"); + signages.put("reactive_power","无功功率"); + signages.put("generation_capacity","正向有功电量"); + signages.put("reactive_generation_capacity","正向无功电量"); + List times = this.sameDayValues(); + Random random = new Random(); + return devices.stream().map(device->{ + GenerationDeviceVo item = new GenerationDeviceVo(); + item.setDeviceCode(device.getNumber()); + item.setDeviceName(device.getName()); + item.setAttributes(signages.entrySet().stream().map(entry->{ + GenerationReportVo attribute = new GenerationReportVo(); + attribute.setAttribute(entry.getKey()); + attribute.setAttributeName(entry.getValue()); + // FIXME : 使用随机数 + attribute.setTimes(times.stream().map(time->{ + GenerationReportTimeVo generation = new GenerationReportTimeVo(); + generation.setTime(time); + generation.setValue(random.nextDouble() * 1000); + return generation; + }).collect(Collectors.toList())); + return attribute; + }).collect(Collectors.toList())); + return item; + }).collect(Collectors.toList()); + } + + /** + * 当天数据值 + * @return + */ + private List sameDayValues() { + Calendar calendar = Calendar.getInstance(); + Date end = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + calendar.add(Calendar.MILLISECOND,-calendar.get(Calendar.MILLISECOND)); + Date start = calendar.getTime(); + List times = new ArrayList<>(); + while (start.compareTo(end) <= 0){ + calendar.add(Calendar.HOUR_OF_DAY,1); + times.add(start.getHours() + "时"); + start = calendar.getTime(); + } + return times; + } +} \ No newline at end of file From 9b09fb2d467f7dbb44dee57fcb0ff3812e946b39 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 27 Jun 2024 08:48:15 +0800 Subject: [PATCH 129/151] =?UTF-8?q?fix=EF=BC=9Achoice=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java | 6 ++++++ .../interactive/service/impl/ChoiceAnswerResolveServiceImpl.java | 6 +++--- .../hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java | 2 +- .../hzims/bigmodel/websocket/handler/InteractiveHandler.java | 9 ++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 9b2ab5f..89c7f3c 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -40,4 +40,10 @@ public class ExtraVO implements Serializable { @ApiModelProperty("选项") private List selection; + @ApiModelProperty("") + private String agentName; + + @ApiModelProperty("") + private Map agentData; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java index 47bb78a..bcc2462 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -35,13 +35,13 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { @Override public ExtraVO getExtra(JSONObject originExtra) { - ExtraVO result = new ExtraVO(); - JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); - result.setSelection(selections); + ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class); result.setSpecial(true); String funcCode = originExtra.getString("func"); result.setFuncCode(funcCode); result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); + JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); + result.setSelection(selections); return result; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java index cb70eb0..39b63fa 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java @@ -69,7 +69,7 @@ public class FrontEndInteractiveSchedule { IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra); JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); return answerResolveService.getExtra(extraObject); - }).toArray(); + }).map(JSON::toJSONString).toArray(); answerVO.setExtras(resolveExtras); } catch(Exception 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 fc6337f..810c022 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 @@ -16,6 +16,7 @@ import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -125,12 +126,10 @@ public class InteractiveHandler extends TextWebSocketHandler { private void handleDefaultChoose(JSONObject messageContext,String sessionId) { IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - String userId = messageContext.getString("userId"); - String funcCode = messageContext.getString("funcCode"); - Map extra = new HashMap<>(2); - extra.put("func",funcCode); + Map extra = messageContext.toJavaObject(Map.class); + extra.put("func",extra.get("funcCode")); extra.put("data",messageContext.getObject("selection", JSONObject.class)); - interactiveService.specialAsk(sessionId,userId,extra); + interactiveService.specialAsk(sessionId, (String) extra.get("userId"),extra); } private void handleVideoChoose(JSONObject messageContext,String sessionId) { From 8573059fc326887f0a8062b7774d0bdce9e118be Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 27 Jun 2024 15:24:12 +0800 Subject: [PATCH 130/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/service/impl/AlarmServiceImpl.java | 90 ++++++++++++++++++++-- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index f822a0a..5459860 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -20,9 +20,13 @@ import com.hnac.hzims.equipment.feign.IEmVideoClient; import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -30,6 +34,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -59,10 +64,15 @@ public class AlarmServiceImpl extends BaseServiceImpl private final IStationClient stationClient; private final IMessageClient messageClient; + private final IEmInfoClient emInfoClient; + private final DeviceClient deviceClient; + private final IEmVideoClient emVideoClient; + private final IStationVideoTypeClient stationVideoTypeClient; + /** * 查询告警列表 * @param alarm @@ -274,9 +284,20 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return 绑定结果 */ private Boolean isRealIdBanding(String realId,String emCode) { - R> deviceAttrR = deviceClient.getOnlineAttr(emCode); - if(deviceAttrR.isSuccess() && CollectionUtil.isNotEmpty(deviceAttrR.getData())) { - return deviceAttrR.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + // 属性 + R> attrs = deviceClient.getOnlineAttr(emCode); + if(attrs.isSuccess() && CollectionUtil.isNotEmpty(attrs.getData())) { + return attrs.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + } + // 事件 + R> events = deviceClient.getOnlineEvent(emCode); + if(events.isSuccess() && CollectionUtil.isNotEmpty(events.getData())) { + return events.getData().stream().anyMatch(event -> realId.equals(event.getFacDeviceEventId())); + } + // 功能 + R> funcs = deviceClient.getOnlineFunc(emCode); + if(funcs.isSuccess() && CollectionUtil.isNotEmpty(funcs.getData())) { + return funcs.getData().stream().anyMatch(func -> realId.equals(func.getSourceAttrSignage())); } return false; } @@ -409,16 +430,71 @@ public class AlarmServiceImpl extends BaseServiceImpl public List alarmVideos(String stationCode, String deviceCode, String realId) { // 根据realId查找 if(StringUtil.isNotBlank(realId)){ - + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(station.isSuccess() && ObjectUtil.isNotEmpty(station)){ + EmInfoEntity param = new EmInfoEntity(); + param.setDepartment(station.getData().getRefDept()); + // 查询设备 + R> devices = emInfoClient.emInfoList(param); + if(devices.isSuccess() && CollectionUtil.isNotEmpty(devices.getData())){ + String deviceCodes = devices.getData().stream().parallel() + .filter(this::isBandingVideoByEmCode) + .filter(this::isDeviceCodeExist) + .map(EmInfoEntity::getNumber) + .filter(number -> this.isRealIdBanding(realId, number)) + .collect(Collectors.joining(",")); + if(StringUtil.isNotBlank(deviceCodes)){ + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCodes); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + } + } + } } // 根据设备编号查找 if(StringUtil.isNotBlank(deviceCode)){ - + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCode); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } } // 根据站点编号查找 if(StringUtil.isNotBlank(stationCode)){ - + List videos = stationVideoTypeClient.listByStationId(stationCode); + if(CollectionUtil.isNotEmpty(videos)){ + return videos.stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getName()); + alarmVideo.setVideoAppKey(video.getAppKey()); + alarmVideo.setVideoAppSecret(video.getAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } } - return new ArrayList<>(); + throw new ServiceException("未查询到告警视频信息!"); } + + } \ No newline at end of file From 4cf2644b02f034171539214deb2d160005344d34 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 28 Jun 2024 11:06:57 +0800 Subject: [PATCH 131/151] =?UTF-8?q?#=E6=99=BA=E8=83=BD=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/show/controller/ShowAlarmController.java | 6 +++--- .../com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 8deca55..d2988ee 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -58,9 +58,9 @@ public class ShowAlarmController extends BladeController { @GetMapping("/alarmVideos") @ApiOperationSupport(order = 4) @ApiOperation(value = "站点") - public R> alarmVideos(@ApiParam("站点编号") @RequestParam String stationCode, - @ApiParam("设备编号") @RequestParam String deviceCode, - @ApiParam("监测点ID") @RequestParam String realId) { + public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, + @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, + @ApiParam("监测点ID") @RequestParam(required = false) String realId) { return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 5459860..51c8aa0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -458,6 +458,9 @@ public class AlarmServiceImpl extends BaseServiceImpl return alarmVideo; }).collect(Collectors.toList()); } + }else{ + // FIXME 查询FDP设备编号 + } } } @@ -466,7 +469,7 @@ public class AlarmServiceImpl extends BaseServiceImpl if(StringUtil.isNotBlank(deviceCode)){ // 查询设备绑定视频点位 R> videos = emVideoClient.getEmBandingVideos(deviceCode); - if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + if(videos.isSuccess() && CollectionUtil.isNotEmpty(videos.getData())){ return videos.getData().stream().distinct().map(video->{ AlarmVideoVo alarmVideo = new AlarmVideoVo(); alarmVideo.setVideoHost(video.getVideoHost()); From c578b6817b57a971c249e59c23917c79a7c64918 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 28 Jun 2024 11:34:50 +0800 Subject: [PATCH 132/151] =?UTF-8?q?#=E9=99=90=E5=88=B6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=9C=88=E5=86=85=E5=B7=A1=E6=A3=80=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 378ce44..8fd6d64 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -334,9 +334,12 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { List fileJson = new ArrayList<>(); // 查询当天数据(条件) String currentDate = DateUtil.formatDateTime(DateUtil.now()); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH,-1); // 巡检任务ID集合 List taskUsers = this.taskUserService.list(new LambdaQueryWrapper() {{ eq(TaskUserEntity::getUserId, user.getUserId()); + ge(TaskUserEntity::getCreateTime, DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE)); }}); if(CollectionUtil.isEmpty(taskUsers)){ throw new ServiceException("巡检用户数据不存在!"); From fb97f63f59cb51b2468da04e6b846bb25027ef75 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 08:16:14 +0800 Subject: [PATCH 133/151] =?UTF-8?q?#=E9=99=90=E5=88=B6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=9C=88=E5=86=85=E5=B7=A1=E6=A3=80=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspect/offline/service/impl/InspectOfflineServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 8fd6d64..a2266d6 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -401,10 +401,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { // 离线任务任务 List offlines = this.tasksData(taskId,fileList); fileJson.add(JsonUtil.toJson(offlines)); - if(fileJson.isEmpty()){ - return; - } - // 文件写入 + // 文件写入 for (int i=0; i < fileJson.size();i++){ TableJsonUtils.createJsonFile(fileJson.get(i), download, tableNames.get(i)); } From 9036bf5556da1b1a949d813502f12554e22c1035 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 11:37:30 +0800 Subject: [PATCH 134/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/controller/ShowAlarmController.java | 5 +- .../hzims/alarm/show/service/AlarmService.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 110 +++++++++++---------- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index d2988ee..4ebda2b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -60,8 +60,9 @@ public class ShowAlarmController extends BladeController { @ApiOperation(value = "站点") public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, - @ApiParam("监测点ID") @RequestParam(required = false) String realId) { - return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); + @ApiParam("监测点ID") @RequestParam(required = false) String realId, + @ApiParam("告警类型") @RequestParam Integer alarmSource) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmSource)); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 0bc7f77..e4cf0d6 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -23,5 +23,5 @@ public interface AlarmService extends BaseService { TextMessage majorAlarm(List depts); - List alarmVideos(String stationCode, String deviceCode, String realId); + List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 51c8aa0..5f77527 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -427,62 +427,23 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List alarmVideos(String stationCode, String deviceCode, String realId) { - // 根据realId查找 - if(StringUtil.isNotBlank(realId)){ - // 查询站点 - R station = stationClient.getStationByCode(stationCode); - if(station.isSuccess() && ObjectUtil.isNotEmpty(station)){ - EmInfoEntity param = new EmInfoEntity(); - param.setDepartment(station.getData().getRefDept()); - // 查询设备 - R> devices = emInfoClient.emInfoList(param); - if(devices.isSuccess() && CollectionUtil.isNotEmpty(devices.getData())){ - String deviceCodes = devices.getData().stream().parallel() - .filter(this::isBandingVideoByEmCode) - .filter(this::isDeviceCodeExist) - .map(EmInfoEntity::getNumber) - .filter(number -> this.isRealIdBanding(realId, number)) - .collect(Collectors.joining(",")); - if(StringUtil.isNotBlank(deviceCodes)){ - // 查询设备绑定视频点位 - R> videos = emVideoClient.getEmBandingVideos(deviceCodes); - if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ - return videos.getData().stream().distinct().map(video->{ - AlarmVideoVo alarmVideo = new AlarmVideoVo(); - alarmVideo.setVideoHost(video.getVideoHost()); - alarmVideo.setVideoName(video.getVideoName()); - alarmVideo.setVideoAppKey(video.getVideoAppKey()); - alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); - alarmVideo.setPointCode(video.getPointCode()); - return alarmVideo; - }).collect(Collectors.toList()); - } - }else{ - // FIXME 查询FDP设备编号 - - } - } - } - } - // 根据设备编号查找 + public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource) { + // 步骤1、根据设备编号查询视频信息 if(StringUtil.isNotBlank(deviceCode)){ - // 查询设备绑定视频点位 - R> videos = emVideoClient.getEmBandingVideos(deviceCode); - if(videos.isSuccess() && CollectionUtil.isNotEmpty(videos.getData())){ - return videos.getData().stream().distinct().map(video->{ - AlarmVideoVo alarmVideo = new AlarmVideoVo(); - alarmVideo.setVideoHost(video.getVideoHost()); - alarmVideo.setVideoName(video.getVideoName()); - alarmVideo.setVideoAppKey(video.getVideoAppKey()); - alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); - alarmVideo.setPointCode(video.getPointCode()); - return alarmVideo; - }).collect(Collectors.toList()); + return this.deviceVideos(stationCode,deviceCode); + } + // 步骤2、根据采集点查询视频信息 + if(StringUtil.isNotBlank(realId)){ + // 智能预警 + if(AlarmConstants.EARLY.equals(alarmSource)){ + this.earlyVideos(stationCode,realId); + }else{ + } } + // 根据站点编号查找 - if(StringUtil.isNotBlank(stationCode)){ + else if(StringUtil.isNotBlank(stationCode)){ List videos = stationVideoTypeClient.listByStationId(stationCode); if(CollectionUtil.isNotEmpty(videos)){ return videos.stream().distinct().map(video->{ @@ -494,10 +455,55 @@ public class AlarmServiceImpl extends BaseServiceImpl alarmVideo.setPointCode(video.getPointCode()); return alarmVideo; }).collect(Collectors.toList()); + }else{ + // 站点不存在视频 } } throw new ServiceException("未查询到告警视频信息!"); } + /** + * 查询设备绑定视频信息 + * @param deviceCode + * @return + */ + private List deviceVideos(String stationCode,String deviceCode) { + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCode); + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + // 查询设备 + R device = emInfoClient.getEmInfoByEmCode(deviceCode); + if(!device.isSuccess() || ObjectUtil.isEmpty(device.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "-" + device.getData().getName() + "视频信息!"); + } + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + + /** + * 查询智能预警视频信息 + * @param stationCode + * @param realId + */ + private void earlyVideos(String stationCode, String realId) { + + + } + + } \ No newline at end of file From de5eee7861e2bc6d6805b358b1818c5922c8a438 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 14:02:16 +0800 Subject: [PATCH 135/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/controller/ShowAlarmController.java | 4 +- .../hzims/alarm/show/service/AlarmService.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 134 ++++++++++++++++----- 3 files changed, 110 insertions(+), 30 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 4ebda2b..42f8dd8 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -61,8 +61,8 @@ public class ShowAlarmController extends BladeController { public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, @ApiParam("监测点ID") @RequestParam(required = false) String realId, - @ApiParam("告警类型") @RequestParam Integer alarmSource) { - return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmSource)); + @ApiParam("告警类型") @RequestParam Integer alarmType) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmType)); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index e4cf0d6..e37fbfa 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -23,5 +23,5 @@ public interface AlarmService extends BaseService { TextMessage majorAlarm(List depts); - List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource); + List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 5f77527..1758414 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.constants.AlarmConstants; @@ -17,6 +18,7 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmVideoClient; +import com.hnac.hzims.fdp.util.HttpRequestUtil; import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -28,7 +30,9 @@ import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; @@ -38,6 +42,7 @@ import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; @@ -48,7 +53,7 @@ import java.util.stream.Collectors; /** * @author ysj */ -@AllArgsConstructor +@RequiredArgsConstructor @Service @Slf4j public class AlarmServiceImpl extends BaseServiceImpl implements AlarmService { @@ -73,6 +78,9 @@ public class AlarmServiceImpl extends BaseServiceImpl private final IStationVideoTypeClient stationVideoTypeClient; + @Value("${hzims.url.getFaultGraphInfo}") + private String FAULTGRAPH_INFO_PATH; + /** * 查询告警列表 * @param alarm @@ -427,7 +435,7 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmSource) { + public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType) { // 步骤1、根据设备编号查询视频信息 if(StringUtil.isNotBlank(deviceCode)){ return this.deviceVideos(stationCode,deviceCode); @@ -435,33 +443,44 @@ public class AlarmServiceImpl extends BaseServiceImpl // 步骤2、根据采集点查询视频信息 if(StringUtil.isNotBlank(realId)){ // 智能预警 - if(AlarmConstants.EARLY.equals(alarmSource)){ - this.earlyVideos(stationCode,realId); + if(AlarmConstants.EARLY.equals(alarmType)){ + return this.earlyVideos(stationCode,realId); + // 通讯中断、通讯异常查询站点视频 + }else if(AlarmConstants.INTERRUPT.equals(alarmType) || AlarmConstants.ABNORMAL.equals(alarmType)){ + return this.stationVideos(stationCode); + // 其他告警 }else{ - + return this.realIdVideos(stationCode,realId); } } - - // 根据站点编号查找 - else if(StringUtil.isNotBlank(stationCode)){ - List videos = stationVideoTypeClient.listByStationId(stationCode); - if(CollectionUtil.isNotEmpty(videos)){ - return videos.stream().distinct().map(video->{ - AlarmVideoVo alarmVideo = new AlarmVideoVo(); - alarmVideo.setVideoHost(video.getVideoHost()); - alarmVideo.setVideoName(video.getName()); - alarmVideo.setVideoAppKey(video.getAppKey()); - alarmVideo.setVideoAppSecret(video.getAppSecret()); - alarmVideo.setPointCode(video.getPointCode()); - return alarmVideo; - }).collect(Collectors.toList()); - }else{ - // 站点不存在视频 - } + // 步骤3.根据站点编号查询视频信息 + if(StringUtil.isNotBlank(stationCode)){ + return this.stationVideos(stationCode); } throw new ServiceException("未查询到告警视频信息!"); } + /** + *查询站点绑定视频信息 + * @param stationCode + */ + private List stationVideos(String stationCode) { + List videos = stationVideoTypeClient.listByStationId(stationCode); + if(CollectionUtil.isEmpty(videos)){ + throw new ServiceException("站点暂无视频信息!"); + + } + return videos.stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getName()); + alarmVideo.setVideoAppKey(video.getAppKey()); + alarmVideo.setVideoAppSecret(video.getAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + /** * 查询设备绑定视频信息 @@ -498,12 +517,73 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 查询智能预警视频信息 * @param stationCode - * @param realId + * @param faultId */ - private void earlyVideos(String stationCode, String realId) { - - + private List earlyVideos(String stationCode, String faultId) { + // 调用FDP接口查询设备编号 + Map param = new HashMap<>(); + param.put("faultId", faultId); + String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST"); + if (StringUtil.isNotBlank(result)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + HashMap map = JSONObject.parseObject(result, new TypeReference>() { + }); + if (ObjectUtil.isEmpty(map)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + List> data = JSONObject.parseObject(MapUtils.getString(map, "data"), new TypeReference>>() { + }); + if (CollectionUtil.isEmpty(data)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + String deviceCode = (String) data.get(0).get("TAOS_INSTANCE"); + if(StringUtil.isNotBlank(deviceCode)){ + throw new ServiceException("未查询到智能预警设备信息!"); + } + return this.deviceVideos(stationCode,deviceCode); } - + /** + * 查询采集点绑定视频信息 + * @param stationCode + * @param realId + */ + private List realIdVideos(String stationCode, String realId) { + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + EmInfoEntity param = new EmInfoEntity(); + param.setDepartment(station.getData().getRefDept()); + // 查询设备 + R> devices = emInfoClient.emInfoList(param); + if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + String deviceCodes = devices.getData().stream().parallel() + .filter(this::isBandingVideoByEmCode) + .filter(this::isDeviceCodeExist) + .map(EmInfoEntity::getNumber) + .filter(number -> this.isRealIdBanding(realId, number)) + .collect(Collectors.joining(",")); + if(StringUtil.isEmpty(deviceCodes)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCodes); + if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!"); + } + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } } \ No newline at end of file From 75be1bf2db998e52d38bfbfdc5ab7eb7fbaac1df Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 1 Jul 2024 16:41:52 +0800 Subject: [PATCH 136/151] =?UTF-8?q?#=E6=8C=87=E6=A0=87=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0try/catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/show/service/impl/AlarmServiceImpl.java | 6 +- .../operation/home/impl/RealTargetServiceImpl.java | 76 +++++++++++++--------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 1758414..10aa732 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -524,7 +524,7 @@ public class AlarmServiceImpl extends BaseServiceImpl Map param = new HashMap<>(); param.put("faultId", faultId); String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST"); - if (StringUtil.isNotBlank(result)) { + if (StringUtil.isBlank(result)) { throw new ServiceException("未查询到智能预警设备信息!"); } HashMap map = JSONObject.parseObject(result, new TypeReference>() { @@ -538,7 +538,7 @@ public class AlarmServiceImpl extends BaseServiceImpl throw new ServiceException("未查询到智能预警设备信息!"); } String deviceCode = (String) data.get(0).get("TAOS_INSTANCE"); - if(StringUtil.isNotBlank(deviceCode)){ + if(StringUtil.isBlank(deviceCode)){ throw new ServiceException("未查询到智能预警设备信息!"); } return this.deviceVideos(stationCode,deviceCode); @@ -573,7 +573,7 @@ public class AlarmServiceImpl extends BaseServiceImpl } // 查询设备绑定视频点位 R> videos = emVideoClient.getEmBandingVideos(deviceCodes); - if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){ + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!"); } return videos.getData().stream().distinct().map(video->{ diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index dfca1da..834ec1c 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; // 创建线程池 - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); @Override public void loadEmInfo(String param) { @@ -281,24 +281,38 @@ public class RealTargetServiceImpl implements RealTargetService { // 水电站设备 List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); if(CollectionUtil.isNotEmpty(devices)){ - targets.addAll(devices.stream().map(device->{ - HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); - target.setDeptId(device.getCreateDept()); - target.setDeviceCode(device.getEmCode()); - target.setDeviceName(device.getName()); - target.setDeptName(device.getName()); - // 当年发电量 - target.setPowerYear(this.getGenerationPower(device,0)); - // 当月发电量 - target.setPowerMon(this.getGenerationPower(device,1)); - // 当日发电量 - target.setPowerDay(this.getGenerationPower(device,2)); - // 当天有功功率 - target.setActivePowerVoList(this.getLoadsByDay(device)); - // 30天发电量 - target.setGenerationPowerVoList(this.getGenerationPowerList(device)); - return target; - }).collect(Collectors.toList())); + CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + for(EminfoAndEmParamVo device : devices) { + pool.submit(() -> { + try{ + HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeviceName(device.getName()); + target.setDeptName(device.getName()); + // 当年发电量 + target.setPowerYear(this.getGenerationPower(device, 0)); + // 当月发电量 + target.setPowerMon(this.getGenerationPower(device, 1)); + // 当日发电量 + target.setPowerDay(this.getGenerationPower(device, 2)); + // 当天有功功率 + target.setActivePowerVoList(this.getLoadsByDay(device)); + // 30天发电量 + target.setGenerationPowerVoList(this.getGenerationPowerList(device)); + targets.add(target); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } + }); + } + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } } // 站点指标数据为空 if(CollectionUtil.isEmpty(targets)){ @@ -1253,16 +1267,20 @@ public class RealTargetServiceImpl implements RealTargetService { CountDownLatch countDownLatch = new CountDownLatch(limits.size()); for(List item : limits){ pool.submit(()->{ - item.forEach(station->{ - // 站点设备集合 - List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - Map generateMap = this.getGenerateYear(station,stationDevices,start,end); - if(MapUtils.isEmpty(generateMap)){ - return; - } - powerMap.put(station.getId(),generateMap); - }); - countDownLatch.countDown(); + try{ + item.forEach(station->{ + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); + }); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); }); From 6e0611662068b11c2f02b1f767178481f78e9fb7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 2 Jul 2024 08:39:40 +0800 Subject: [PATCH 137/151] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=B1=BB=E5=9E=8B=E7=AB=99=E7=82=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/show/vo/ShowQueryVo.java | 28 ++++++++++ .../hzims/business/ws/alart/vo/AlartParamVo.java | 21 ++++++++ .../alarm/show/controller/ShowAlarmController.java | 14 ++--- .../hzims/alarm/show/service/AlarmService.java | 10 ++-- .../alarm/show/service/impl/AlarmServiceImpl.java | 59 +++++++++++----------- .../hnac/hzims/alarm/ws/alart/AlarmHandler.java | 9 ++-- 6 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java new file mode 100644 index 0000000..bee063e --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.alarm.show.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author ysj + * @date 2023/03/17 10:02:33 + * @version 4.0.0 + */ +@Data +public class ShowQueryVo { + + @ApiModelProperty(value = "站点编号") + private String stationId; + + @ApiModelProperty(value = "站点类型") + private Integer serveType; + + @ApiModelProperty(value = "告警类型 :0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警") + private Integer alarmSource; + + @ApiModelProperty(value = "告警子类") + private Integer alarmType; +} + diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java new file mode 100644 index 0000000..06123de --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.business.ws.alart.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "告警弹框参数", description = "") +public class AlartParamVo { + + @ApiModelProperty("站点类型: 2-云服务 1-代运维") + private Integer serveType; + + @ApiModelProperty("用户权限机构集合") + private List depts; +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 42f8dd8..b8aec8c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; @@ -37,22 +38,23 @@ public class ShowAlarmController extends BladeController { @ApiOperationSupport(order = 1) @ApiOperation(value = "播报告警", notes = "传入:时间区间") public R> broadcast(@ApiParam(value = "开始时间") String startTime, - @ApiParam(value = "结束时间", required = true) String endTime) { - return R.data(alarmService.broadcast(startTime,endTime)); + @ApiParam(value = "结束时间", required = true) String endTime, + @ApiParam(value = "站点类型") Integer serveType) { + return R.data(alarmService.broadcast(startTime,endTime,serveType)); } @PostMapping("/show") @ApiOperationSupport(order = 2) @ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数") - public R> alarms(AlarmEntity alarm, Query query) { - return R.data(alarmService.alarms(alarm,Condition.getPage(query))); + public R> alarms(ShowQueryVo showQuery, Query query) { + return R.data(alarmService.alarms(showQuery,Condition.getPage(query))); } @PostMapping("/count") @ApiOperationSupport(order = 3) @ApiOperation(value = "告警分类数量", notes = "不需要传入参数") - public R> counts(@RequestBody AlarmEntity alarm) { - return R.data(alarmService.counts(alarm)); + public R> counts(@RequestBody ShowQueryVo showCount) { + return R.data(alarmService.counts(showCount)); } @GetMapping("/alarmVideos") diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index e37fbfa..064489d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -15,13 +17,13 @@ import java.util.List; */ public interface AlarmService extends BaseService { - IPage alarms(AlarmEntity alarm, IPage page); + IPage alarms(ShowQueryVo showQuery, IPage page); - List counts(AlarmEntity alarm); + List counts(ShowQueryVo showCount); - List broadcast(String startTime, String endTime); + List broadcast(String startTime, String endTime,Integer serveType); - TextMessage majorAlarm(List depts); + TextMessage majorAlarm(AlartParamVo param); List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 10aa732..2e69bc6 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -13,7 +13,9 @@ import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -29,7 +31,6 @@ import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; -import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -37,14 +38,12 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import java.util.*; @@ -83,13 +82,13 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 查询告警列表 - * @param alarm + * @param showQuery * @param page * @return */ @Override - public IPage alarms(AlarmEntity alarm, IPage page) { - List stations = this.stations(); + public IPage alarms(ShowQueryVo showQuery, IPage page) { + List stations = this.stations(showQuery.getServeType()); if(CollectionUtil.isEmpty(stations)){ return page; } @@ -100,14 +99,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showQuery.getStationId())){ + wrapper.eq("STATION_ID",showQuery.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showQuery.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showQuery.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showQuery.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } // 处理告警过滤 :当天处理告警 @@ -124,9 +123,11 @@ public class AlarmServiceImpl extends BaseServiceImpl * 获取权限站点 * @return */ - private List stations() { + private List stations(Integer serveType) { StationEntity station = new StationEntity(); - station.setServeType("2"); + if(ObjectUtil.isNotEmpty(serveType)){ + station.setServeType(String.valueOf(serveType)); + } station.setType(0); R> result = stationClient.list(station); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ @@ -140,9 +141,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List counts(AlarmEntity alarm) { + public List counts(ShowQueryVo showCount) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(showCount.getServeType()); if(CollectionUtil.isEmpty(stations)){ return AlarmConstants.ALARAM_SOURCE.stream().map(source->{ AlarmCountVo count = new AlarmCountVo(); @@ -157,14 +158,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showCount.getStationId())){ + wrapper.eq("STATION_ID",showCount.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showCount.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showCount.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showCount.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showCount.getAlarmType()); } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -194,9 +195,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List broadcast(String startTime, String endTime) { + public List broadcast(String startTime, String endTime,Integer serveType) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(serveType); if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); } @@ -214,17 +215,17 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 弹框告警 - * @param depts + * @param param * @return */ @Override - public TextMessage majorAlarm(List depts) { + public TextMessage majorAlarm(AlartParamVo param) { // 站点查询 - List stations = this.stations(); - if(CollectionUtil.isEmpty(stations)){ + List stations = this.stations(param.getServeType()); + if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ return new TextMessage(new ArrayList().toString()); } - List effectives = stations.stream().filter(station->depts.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); + List effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(effectives)){ return new TextMessage(new ArrayList().toString()); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index 373ef43..f6052a0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -2,8 +2,8 @@ package com.hnac.hzims.alarm.ws.alart; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +13,6 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; -import java.util.List; /** * @author ysj @@ -57,11 +56,11 @@ public class AlarmHandler extends TextWebSocketHandler { if(StringUtil.isBlank(message)){ return; } - List depts = JSONObject.parseArray(message,Long.class); - if(CollectionUtil.isEmpty(depts)){ + AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class); + if(ObjectUtil.isEmpty(param)){ return; } - TextMessage sendMessage = alarmService.majorAlarm(depts); + TextMessage sendMessage = alarmService.majorAlarm(param); session.sendMessage(sendMessage); } } From 85384b11b3b17bdbf7282e20c7ad6344faff47d9 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 2 Jul 2024 10:59:37 +0800 Subject: [PATCH 138/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 7 +- hzims-service/hzims-big-model/pom.xml | 4 + .../hzims/bigmodel/HzimsBigModelApplication.java | 3 +- .../controller/DataSourceExecuteController.java | 26 +++++ .../datasource/service/DataSourceService.java | 51 ++++++++++ .../datasource/service/IDataSourceService.java | 14 +++ .../function/controller/FunctionController.java | 2 +- .../interactive/constants/ParamKeyConstants.java | 19 ++++ .../controller/AnalyseDataController.java | 1 + .../controller/FontEndInteractiveController.java | 8 ++ .../controller/HznlmInteractiveController.java | 3 +- .../controller/InteractiveController.java | 1 + .../interactive/factory/AnswerResolveFactory.java | 3 +- .../service/IHznlmInteractiveService.java | 3 +- .../interactive/service/IResolveService.java | 4 +- .../service/impl/AnalyseDataServiceImpl.java | 2 +- .../service/impl/CanvasResolveServiceImpl.java | 112 ++++++++++++++++++++- .../impl/ChoiceAnswerResolveServiceImpl.java | 2 +- .../impl/DiagnoseAnswerResolveServiceImpl.java | 2 +- .../service/impl/ExtraResolveStrategyService.java | 12 +-- .../service/impl/HznlmInteractiveServiceImpl.java | 9 +- .../service/impl/HznlmInvokeServiceImpl.java | 6 +- .../service/impl/InteractiveServiceImpl.java | 2 +- .../service/impl/JumpRouteJoinStrategy.java | 2 +- .../impl/ParamAnswerResolveServiceImpl.java | 4 +- .../interactive/service/impl/ParamStrategy.java | 2 +- .../impl/RemoteAnswerResolveServiceImpl.java | 2 +- .../service/impl/VideoResolveServiceImpl.java | 14 +-- .../schedule/FrontEndInteractiveSchedule.java | 7 +- .../hzims/bigmodel/utils/RequestClientUtil.java | 5 +- .../websocket/handler/InteractiveHandler.java | 9 +- pom.xml | 5 + 32 files changed, 294 insertions(+), 52 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index 89c7f3c..d01b6e6 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.vo; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -26,7 +27,7 @@ public class ExtraVO implements Serializable { private String label; @ApiModelProperty("函数编号") - private String funcCode; + private String func; @ApiModelProperty("是否立即跳转") private boolean isImmediatelyJump = false; @@ -40,10 +41,10 @@ public class ExtraVO implements Serializable { @ApiModelProperty("选项") private List selection; - @ApiModelProperty("") + @JSONField(name = "agent_name") private String agentName; - @ApiModelProperty("") + @JSONField(name = "agent_data") private Map agentData; } diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index 91ae6d1..e1ebe29 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -79,6 +79,10 @@ com.hnac.hzims equipment-api + + com.baomidou + dynamic-datasource-spring-boot-starter + diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java index 0f09cc7..3d58539 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/HzimsBigModelApplication.java @@ -18,9 +18,8 @@ import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMO @EnableBladeFeign(basePackages = {"org.springblade","com.hnac"}) @SpringCloudApplication @MapperScan("com.hnac.hzims.**.mapper.**") -@ComponentScan(basePackages = {"com.hnac.hzims.bigmodel.*"}) @Resource -@ComponentScan(basePackages = {"com.hnac.hzims.*"}) +@ComponentScan(basePackages = {"com.hnac.hzims.**"}) @Slf4j public class HzimsBigModelApplication extends SpringBootServletInitializer { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java new file mode 100644 index 0000000..84172fe --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.bigmodel.datasource.controller; + +import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: huangxing + * @Date: 2024/06/28 14:07 + */ +@RestController +@RequestMapping("/dataSource/execute") +@AllArgsConstructor +public class DataSourceExecuteController { + + private final DataSourceService dataSourceService; + + @GetMapping("/executeQuery") + public R executeQuery(String sql,String dataSourceName) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sql,dataSourceName)); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java new file mode 100644 index 0000000..262d871 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java @@ -0,0 +1,51 @@ +package com.hnac.hzims.bigmodel.datasource.service; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/28 15:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class DataSourceService { + + private final JdbcTemplate jdbcTemplate; + + /** + * 指定 + * @param sql + * @param dataSourceName + * @return + */ + public List> queryListOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.queryForList(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + + public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.update(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java new file mode 100644 index 0000000..1f0e802 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.bigmodel.datasource.service; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/28 14:22 + */ +public interface IDataSourceService { + + List> queryList(String sql); + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java index bffa1db..1d63c64 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java @@ -41,7 +41,7 @@ public class FunctionController { return R.status(functionService.save(req)); } - @PutMapping("/save") + @PutMapping("/updateById") @ApiOperation("编辑函数") @ApiOperationSupport(order = 2) public R updateById(@RequestBody FunctionEntity req) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java new file mode 100644 index 0000000..cb7b02a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +/** + * @Author: huangxing + * @Date: 2024/07/01 14:26 + * @Describe: 参数key管理 + */ +public interface ParamKeyConstants { + + /**实时画面host**/ + String CANVAS_HOST = "hzims:bigModel:canvas:host"; + /**实时画面v3路径 {context}&stationNum={stationNum}&projectId={projectId}**/ + String CANVAS_V3_PATH = "hzims:bigModel:canvas:v3:path"; + /**实时画面v4路径 other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}**/ + String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path"; + /**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/ + String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path"; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java index 5ecf019..d09637f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor @Api(value = "数据查询管理",tags = "数据查询管理") @RestController +@Deprecated public class AnalyseDataController { private final IAnalyseDataService analyseDataService; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java index 8ec9e8a..9d0afe8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.controller; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.BigModelConstants; @@ -52,4 +53,11 @@ public class FontEndInteractiveController { public R> hotQuestions() { return R.data(hznlmInvokeService.hotQuestions()); } + + @ApiOperation("获取问答sessionId") + @ApiOperationSupport(order = 4) + @GetMapping("/getSessionId") + public R getSessionId() { + return R.data(IdWorker.get32UUID()); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 3924173..958f103 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -6,6 +6,7 @@ import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; @@ -40,7 +41,7 @@ public class HznlmInteractiveController { @ApiOperation("解析大模型函数") @ApiOperationSupport(order = 2) @PostMapping("/resolve") - public R resolve(@RequestBody @Valid ModelFunctionReq req) { + public R resolve(@RequestBody @Valid ModelFunctionReq req) { return R.data(interactiveService.resolve(req)); } } 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 ca90465..35537ee 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 @@ -28,6 +28,7 @@ import java.util.List; @Api(value = "FDP大模型交互层",tags = "FDP大模型交互层") @RequestMapping("/interactive") @Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层") +@Deprecated public class InteractiveController { private final IInteractiveService interactiveService; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java index 9595974..b9daa43 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java +++ b/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 CHOICE_ANSWER_SERVICE = "choiceAnswerResolveService"; 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 IAnswerResolveService getResolveService(Object extra) { String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func"); @@ -45,7 +46,7 @@ public class AnswerResolveFactory { case SHOW_PARAM: return SpringUtil.getBean(PARAM_ANSWER_SERVICE); default: - throw new ServiceException("service解析失败!"); + return null; } } throw new ServiceException("service解析失败!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java index 6239980..ec26387 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import org.springframework.web.bind.annotation.RequestBody; @@ -17,5 +18,5 @@ public interface IHznlmInteractiveService { List getAuthData(@RequestBody @Valid AuthDataDTO req); - ResolveResultVO resolve(ModelFunctionReq req); + ExtraVO resolve(ModelFunctionReq req); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java index 97c6aa4..19a5869 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IResolveService.java @@ -10,8 +10,8 @@ import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; */ public interface IResolveService { - ExtraVO resolve(Long id); + ExtraVO resolve(String id); - ResolveResultVO resolve(ModelFunctionReq req); + ExtraVO resolve(ModelFunctionReq req); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 9ff9828..418f66c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -57,7 +57,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { searchVO.setDataType(adapterDate.getDateType()); ExtraVO extraVO = new ExtraVO(); extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); - extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFuncCode()); Map params = new HashMap<>(1); Result reductionDataVOR = historyDataService.getPolymerizationData(searchVO); String label; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java index 4ae5cd5..3016a6b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -1,14 +1,30 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants; import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.cache.ParamCache; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.*; +import java.util.stream.IntStream; /** * @Author: huangxing @@ -19,15 +35,101 @@ import org.springframework.stereotype.Service; @Slf4j public class CanvasResolveServiceImpl implements IResolveService { - private final ScadaClient scadaClient; + private final IStationClient stationClient; + private final BladeLogger logger; @Override - public ResolveResultVO resolve(ModelFunctionReq req) { - return null; + public ExtraVO resolve(ModelFunctionReq req) { + Map args = req.getFunctionArgs(); + String id = args.get("id"); + String name = args.get("name"); + Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { + logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req)); + throw new ServiceException("解析传参错误,缺少必要参数video_id"); + }); + return this.resolve(id); +// ExtraVO extra = this.resolve(id); +// String message = "已成功打开" + name + ";"; +// return new ResolveResultVO(message,extra); } @Override - public ExtraVO resolve(Long id) { - return null; + public ExtraVO resolve(String id) { + ExtraVO extraVO = new ExtraVO(); + extraVO.setImmediatelyJump(true); + extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); + final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; + String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); + // 将ID解析为 + Map resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); + R stationR = stationClient.getStationByCode(resolveMap.get("projectId")); + extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name")); + Integer picResource = Integer.valueOf(resolveMap.get("picResource")); + Map extraParams = new HashMap<>(1); + extraParams.put("picResource",picResource); + extraVO.setParams(extraParams); + // 云组态 + if(picResource == 0) { + String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_YZT_PATH), resolveMap); + extraVO.setRoute(canvasHost + path); + } + // v3.0 + else if(picResource == 1) { + String path = this.replacePath(ParamCache.getValue(ParamKeyConstants.CANVAS_V3_PATH), resolveMap); + extraVO.setRoute(canvasHost + path); + } + // v4.0 + else if (picResource == 2) { + // pic_name 去掉头部的/ 以及尾部的.js + String context = resolveMap.get("context"); + context = this.removeHeadChars(context,"/"); + context = this.removeTailChars(context,".js"); + resolveMap.put("context",context); + extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}", resolveMap)); + } + else { + throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); + } + return extraVO; + } + + public 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); + }); + IntStream.iterate(0, index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); + return result; + } + + private String replacePath(String path,Map params) { + Set> entries = params.entrySet(); + // 替换path中变量 + for (Map.Entry entry : entries) { + String replaceVariables = "{" + entry.getKey() + "}"; + path = StringUtil.replace(path,replaceVariables,entry.getValue()); + } + return path; + } + + public String removeHeadChars(String str, String charsToRemove) { + if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { + return str; + } + while (str.startsWith(charsToRemove)) { + str = str.substring(charsToRemove.length()); + } + return str; + } + + public String removeTailChars(String str, String charsToRemove) { + if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { + return str; + } + while (str.endsWith(charsToRemove)) { + str = str.substring(0, str.length() - charsToRemove.length()); + } + return str; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java index bcc2462..568bd50 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -38,7 +38,7 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class); result.setSpecial(true); String funcCode = originExtra.getString("func"); - result.setFuncCode(funcCode); + result.setFunc(funcCode); result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); result.setSelection(selections); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java index b0dcc7f..fa94148 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/DiagnoseAnswerResolveServiceImpl.java @@ -43,7 +43,7 @@ public class DiagnoseAnswerResolveServiceImpl implements IAnswerResolveService { params.put("fdpOrd",data.getString("ord")); result.setParams(params); String funcCode = originExtra.getString("func"); - result.setFuncCode(funcCode); + result.setFunc(funcCode); result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); return result; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 40e7b0d..05f54db 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -82,7 +82,7 @@ public class ExtraResolveStrategyService { private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) { ExtraVO result = new ExtraVO(); JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data"))); - result.setFuncCode(funcRouteEnum.getFuncCode()); + result.setFunc(funcRouteEnum.getFuncCode()); result.setSpecial(true); result.setSelection(selections); result.setType(funcRouteEnum.getType().getType()); @@ -132,7 +132,7 @@ public class ExtraResolveStrategyService { } } ExtraVO result = new ExtraVO(); - result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); + result.setFunc(FuncRouteEnum.SHOW_PARAM.getFuncCode()); result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); Map param = new HashMap(1); param.put("data", data); @@ -144,7 +144,7 @@ public class ExtraResolveStrategyService { private ExtraVO resolveConfirmRemote(Map extra) { ExtraVO result = new ExtraVO(); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); - result.setFuncCode(FuncRouteEnum.CONFIRM_YK.getFuncCode()); + result.setFunc(FuncRouteEnum.CONFIRM_YK.getFuncCode()); result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); if(funcVOR.isSuccess()) { @@ -182,7 +182,7 @@ public class ExtraResolveStrategyService { params.put("fdpDeviceName",data.getString("device_name")); params.put("fdpOrd",data.getString("ord")); result.setParams(params); - result.setFuncCode(FuncRouteEnum.DIAGNOSE.getFuncCode()); + result.setFunc(FuncRouteEnum.DIAGNOSE.getFuncCode()); result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); return result; } @@ -229,7 +229,7 @@ public class ExtraResolveStrategyService { } return selectionVO; }).collect(Collectors.toList()); - result.setFuncCode(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode()); + result.setFunc(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode()); result.setSpecial(true); result.setSelection(selections); } @@ -249,7 +249,7 @@ public class ExtraResolveStrategyService { selectionVO.setName(resolve.get("name")); return selectionVO; }).collect(Collectors.toList()); - result.setFuncCode(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode()); + result.setFunc(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode()); result.setSpecial(true); result.setSelection(selections); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java index 2ccc41f..fc0567f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java @@ -7,6 +7,7 @@ import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; @@ -43,13 +44,9 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { } @Override - public ResolveResultVO resolve(ModelFunctionReq req) { + public ExtraVO resolve(ModelFunctionReq req) { IResolveService resolveService = ResolveFactory.getResolveService(req.getFunctionName()); - try { - return resolveService.resolve(req); - } catch (Exception e) { - return ResolveResultVO.error(); - } + return resolveService.resolve(req); } public List getDeptAuthData(String userId) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index a09ffa0..db48d34 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -11,6 +11,7 @@ import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.manager.SessionRedisManager; import com.hnac.hzims.bigmodel.utils.RequestClientUtil; +import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; @@ -69,6 +70,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { params.put("extra",extra); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); + log.info("调用大模型接口:{},传参为:{}",fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(),JSON.toJSONString(params)); RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), params); sessionRedisManager.addSessionId(sessionId); } @@ -91,6 +93,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { Map params = new HashMap<>(); params.put("id",sessionId); RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params); + // 移除内存sessionId + InteractiveSessionManager.SESSION_POOL.remove(sessionId); sessionRedisManager.removeSessionId(sessionId); } @@ -119,7 +123,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId) .filter(StringUtil::isNotBlank).toArray(String[]::new); String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId) - .filter(Func::isNotEmpty).toArray(String[]::new); + .filter(Func::isNotEmpty).map(String::valueOf).toArray(String[]::new); result.put("stationids", stationIds); result.put("projectids", projectIds); return result; 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 d5e1e6e..a5eff60 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 @@ -108,7 +108,7 @@ public class InteractiveServiceImpl implements IInteractiveService { public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) { ExtraVO extraVO = new ExtraVO(); extraVO.setType(TypeEnum.PARAMS.getType()); - extraVO.setFuncCode("stations_num"); + extraVO.setFunc("stations_num"); String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) { 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 b5b6b5f..e2e1cbd 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 @@ -54,7 +54,7 @@ public class JumpRouteJoinStrategy { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); - extraVO.setFuncCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java index 507b306..8a52994 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamAnswerResolveServiceImpl.java @@ -57,11 +57,11 @@ public class ParamAnswerResolveServiceImpl implements IAnswerResolveService { } else if(StringUtil.isNotBlank(data.getType()) && SearchTypeEnum.HISTORY.getSearchType().equals(data.getType())) { // 处理查询历史数据 - this.getHistoryData(data); + return this.getHistoryData(data); } String funcCode = originExtra.getString("func"); ExtraVO result = new ExtraVO(); - result.setFuncCode(funcCode); + result.setFunc(funcCode); result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); Map param = new HashMap(1); param.put("data", data); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index 67e49a0..e2a37b2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -57,7 +57,7 @@ public class ParamStrategy { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); extraVO.setImmediatelyJump(true); - extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); Map params = new HashMap<>(); params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java index 95f271a..09cc711 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/RemoteAnswerResolveServiceImpl.java @@ -42,7 +42,7 @@ public class RemoteAnswerResolveServiceImpl implements IAnswerResolveService { ExtraVO result = new ExtraVO(); RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(originExtra.get("data")), RemoteParamVO.class); String funcCode = originExtra.getString("func"); - result.setFuncCode(funcCode); + result.setFunc(funcCode); result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); if(funcVOR.isSuccess()) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java index 3cdc225..ee17050 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java @@ -36,7 +36,7 @@ public class VideoResolveServiceImpl implements IResolveService { private final BladeLogger logger; @Override - public ResolveResultVO resolve(ModelFunctionReq req) { + public ExtraVO resolve(ModelFunctionReq req) { Map args = req.getFunctionArgs(); String id = args.get("id"); String name = args.get("name"); @@ -44,13 +44,15 @@ public class VideoResolveServiceImpl implements IResolveService { logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req)); throw new ServiceException("解析传参错误,缺少必要参数video_id"); }); - ExtraVO extra = this.resolve(Long.valueOf(id)); - String message = "已成功打开" + name + ";"; - return new ResolveResultVO(message,extra); + return this.resolve(id); +// ExtraVO extra = this.resolve(id); +// String message = "已成功打开" + name + ";"; +// return new ResolveResultVO(message,extra); } @Override - public ExtraVO resolve(Long id) { + public ExtraVO resolve(String idStr) { + Long id = Long.valueOf(idStr); // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); R videoR = videoClient.getById(Long.valueOf(id)); @@ -58,7 +60,7 @@ public class VideoResolveServiceImpl implements IResolveService { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); extraVO.setImmediatelyJump(true); - extraVO.setFuncCode(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); Map params = new HashMap<>(); params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java index 39b63fa..be768ed 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java @@ -67,8 +67,11 @@ public class FrontEndInteractiveSchedule { // 解析答案 Object[] resolveExtras = Arrays.stream(extras).map(extra -> { IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra); - JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); - return answerResolveService.getExtra(extraObject); + if(Func.isNotEmpty(answerResolveService)) { + JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra)); + return answerResolveService.getExtra(extraObject); + } + return extra; }).map(JSON::toJSONString).toArray(); answerVO.setExtras(resolveExtras); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java index a878fff..229fc12 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -5,7 +5,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import groovy.util.logging.Slf4j; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springframework.util.Assert; @@ -16,6 +16,7 @@ import java.util.Map; * @Author: huangxing * @Date: 2024/06/21 17:12 */ +@Slf4j public class RequestClientUtil { /** @@ -34,7 +35,7 @@ public class RequestClientUtil { * 远程调用http接口 * @param url 接口url * @param body 传参 - * @param resultT 结果解析对象 + * @param typeRef 结果解析对象 * @return 结果 * @param 结果解析对象类型 */ 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 810c022..d2e05d7 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 @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; import com.hnac.hzims.bigmodel.interactive.vo.*; @@ -103,7 +104,7 @@ public class InteractiveHandler extends TextWebSocketHandler { } } else { - String funcCode = messageContext.getString("funcCode"); + String funcCode = messageContext.getString("func"); FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); switch (funcEnum) { case CHOOSE_STATION: @@ -125,11 +126,11 @@ public class InteractiveHandler extends TextWebSocketHandler { } private void handleDefaultChoose(JSONObject messageContext,String sessionId) { - IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + IHznlmInvokeService invokeService = SpringUtil.getBean(IHznlmInvokeService.class); Map extra = messageContext.toJavaObject(Map.class); - extra.put("func",extra.get("funcCode")); + extra.put("func",extra.get("func")); extra.put("data",messageContext.getObject("selection", JSONObject.class)); - interactiveService.specialAsk(sessionId, (String) extra.get("userId"),extra); + invokeService.specialAsk(sessionId, (String) extra.get("userId"),extra); } private void handleVideoChoose(JSONObject messageContext,String sessionId) { diff --git a/pom.xml b/pom.xml index fee8f9d..31b5875 100644 --- a/pom.xml +++ b/pom.xml @@ -212,6 +212,11 @@ easypoi-spring-boot-starter ${easpoi.version} + + com.baomidou + dynamic-datasource-spring-boot-starter + 2.5.6 + From 64a292f39cd13b6e508335ca91e1264a3428bdf2 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 1 Jul 2024 16:48:38 +0800 Subject: [PATCH 139/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=A6?= =?UTF-8?q?=E8=BE=86=E5=B9=B4=E5=BA=A6=E9=87=8C=E7=A8=8B=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java | 4 ++++ .../main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml | 5 ++--- .../hnac/hzims/safeproduct/service/impl/CarServiceImpl.java | 11 ++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java index c73f78e..b9355a2 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * @author liwen @@ -78,4 +79,7 @@ public class CarMilesYearVO { @ExcelProperty(value = "合计里程/km", order = 15) @ApiModelProperty("合计里程数") private BigDecimal sumMiles; + + @ApiModelProperty("创建时间") + private Date createTime; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml index 6080ea6..61bea9f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml @@ -4,7 +4,7 @@ SELECT - t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles, - t1.create_user, t1.create_dept + t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles FROM hzims_car t1 LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index a46457a..90fadf4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.safeproduct.entity.CarEntity; import com.hnac.hzims.safeproduct.mapper.CarMapper; import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; +import org.apache.commons.collections4.map.HashedMap; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -29,6 +30,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -71,7 +73,7 @@ public class CarServiceImpl extends ServiceImpl implements } List carList = records.stream().map(CarMilesYearVO::getPlateNumber).collect(Collectors.toList()); List milesList = baseMapper.selectMilesByCar(carList, year); - List res = new ArrayList<>(); + HashedMap map = new HashedMap<>(); milesList.forEach(data -> { CarMilesYearVO carMilesYearVO = records.stream().filter(x -> x.getPlateNumber().equals(data.getPlateNumber())) .collect(Collectors.toList()).get(0); @@ -127,11 +129,14 @@ public class CarServiceImpl extends ServiceImpl implements carMilesYearVO.setSumMiles(sum.add(data.getMiles())); } if (!carMilesYearVO.getSumMiles().equals(new BigDecimal(0))) { - res.add(carMilesYearVO); + map.put(carMilesYearVO.getPlateNumber(), carMilesYearVO); } }); + List list = new ArrayList<>(map.values()); + List res = list.stream().sorted(Comparator.comparing(CarMilesYearVO::getCreateTime).reversed()) + .collect(Collectors.toList()); page.setRecords(res); - page.setTotal(res.size()); + page.setTotal(carPage.getTotal()); return page; } From 09de77d57eb8584334b3a803bd1a02c27399c764 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jul 2024 14:34:01 +0800 Subject: [PATCH 140/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=AB?= =?UTF-8?q?=E7=94=9F=E8=A1=A8=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/HygieneRecordServiceImpl.java | 4 ++-- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 5392c0a..18a3297 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -194,8 +194,8 @@ public class HygieneRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(hygieneRecordDetailVO); String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String pdfPath = savePath + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; + String wordPath = "D:/" + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; + String pdfPath = "D:/" + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, "",response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index c80b1ba..2c1755e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -144,10 +144,10 @@ public class BaseUtil { } } // 表格处理 - if (templatePath.equals("template/卫生自查表.docx")) { + if ("template/卫生自查表.docx".equals(templatePath)) { formatHygieneRecordTable(xwpfDocument); } - if (templatePath.equals("template/车辆检查表.docx")) { + if ("template/车辆检查表.docx".equals(templatePath)) { formatCarCheckRecordTable(xwpfDocument); } } catch (Exception e) { @@ -225,13 +225,18 @@ public class BaseUtil { List rows = table.getRows(); // 第三行到倒数第二行为需合并区域 for (int row = 3; row < rows.size() - 1;) { - XWPFTableCell startCell = rows.get(row).getCell(0); - String startText = startCell.getText(); + // 判断责任区和责任人是否完全一致,一致则合并 + XWPFTableCell startFirstCell = rows.get(row).getCell(0); + String startFirstText = startFirstCell.getText(); + XWPFTableCell startSecondCell = rows.get(row).getCell(1); + String startSecondText = startSecondCell.getText(); int index = row + 1; for (; index < rows.size(); index++) { - XWPFTableCell endCell = rows.get(index).getCell(0); - String endText = endCell.getText(); - if (!startText.equals(endText)) { + XWPFTableCell endFirstCell = rows.get(index).getCell(0); + String endFirstText = endFirstCell.getText(); + XWPFTableCell endSecondCell = rows.get(index).getCell(1); + String endSecondText = endSecondCell.getText(); + if (!startFirstText.equals(endFirstText) || !startSecondText.equals(endSecondText)) { break; } } From 0fec9dbd61170780acb6c8878701245422865c76 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jul 2024 15:59:57 +0800 Subject: [PATCH 141/151] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=AB?= =?UTF-8?q?=E7=94=9F=E8=A1=A8=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 18a3297..5392c0a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -194,8 +194,8 @@ public class HygieneRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(hygieneRecordDetailVO); String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String wordPath = "D:/" + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; - String pdfPath = "D:/" + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; + String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX; + String pdfPath = savePath + "/卫生自查表" + SafeProductConstant.PDF_SUFFIX; BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, "",response); } From 09cf4b5536d75db8c8c1d95ab17bb5b0f4a082b7 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 2 Jul 2024 19:03:17 +0800 Subject: [PATCH 142/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java | 3 ++- .../hnac/hzims/bigmodel/data/service/HistoryDataService.java | 2 +- .../hzims/bigmodel/datasource/service/DataSourceService.java | 11 +++++++++++ .../hzims/bigmodel/interactive/constants/FuncRouteEnum.java | 4 ++-- .../com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 1 + .../hzims/bigmodel/websocket/handler/InteractiveHandler.java | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java index 914f25b..15bb8c3 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java @@ -17,7 +17,7 @@ public class DataItemVO implements Serializable { @JSONField(name = "id") private String attrId; - @JSONField(name = "param_name") + @JSONField(name = "record_name") private String attrName; @JSONField(name = "device_name") @@ -32,6 +32,7 @@ public class DataItemVO implements Serializable { @JSONField(name = "station_name") private String projectName; + @JSONField(name = "record_id") private String signage; private String units; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java index 4a3fc76..a9f854c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java @@ -34,7 +34,7 @@ public class HistoryDataService { private final DeviceDataClient deviceDataClient; private final BladeLogger logger; - public static final int DATA_COUNT_MAX = 8000; + public static final int DATA_COUNT_MAX = 1000; public Result getPolymerizationData(HistoryDataSearchVO searchVO) { DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java index 262d871..d858de3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; /** * @Author: huangxing @@ -20,6 +21,9 @@ public class DataSourceService { private final JdbcTemplate jdbcTemplate; + private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); + private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); + /** * 指定 * @param sql @@ -48,4 +52,11 @@ public class DataSourceService { } } + public static boolean isUpdateOrDelete(String sql) { + if (sql == null) { + return false; + } + return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); + } + } 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 ef03d20..c3baac3 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 @@ -14,14 +14,14 @@ import java.util.Optional; public enum FuncRouteEnum { OPEN_CANVAS("open_canvas","打开实时画面",FunctionConstants.TypeEnum.JUMP), OPEN_VIDEO("open_video","打开视频监控",FunctionConstants.TypeEnum.PARAMS), - DIAGNOSE("diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS), + DIAGNOSE("result_diagnose","智能诊断",FunctionConstants.TypeEnum.PARAMS), CHOOSE_STATION("choose_station","选择站点",FunctionConstants.TypeEnum.CHOOSE), CHOOSE_VIDEO("choose_video","选择视频",FunctionConstants.TypeEnum.CHOOSE), CHOOSE_CANVAS("choose_canvas","选择画面",FunctionConstants.TypeEnum.CHOOSE), CHOOSE_FAULT("choose_fault","选择故障",FunctionConstants.TypeEnum.CHOOSE), CHOOSE_YK("choose_yk","选择遥控",FunctionConstants.TypeEnum.CHOOSE), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), - SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), + SHOW_PARAM("result_record","设备参数查询", FunctionConstants.TypeEnum.PARAMS), CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART), ; 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 cc5cde6..6ca3031 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 @@ -46,6 +46,7 @@ import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; */ @Component @AllArgsConstructor +@Deprecated public class InteractiveSchedule { private final InteractiveWsService wsService; 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 d2e05d7..594981b 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 @@ -129,7 +129,7 @@ public class InteractiveHandler extends TextWebSocketHandler { IHznlmInvokeService invokeService = SpringUtil.getBean(IHznlmInvokeService.class); Map extra = messageContext.toJavaObject(Map.class); extra.put("func",extra.get("func")); - extra.put("data",messageContext.getObject("selection", JSONObject.class)); + extra.put("data",JSONObject.parseObject(JSON.toJSONString(extra.get("selection")))); invokeService.specialAsk(sessionId, (String) extra.get("userId"),extra); } From 8753807b1d2e9ef9274bfb6622f5cb8877c5ed12 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 3 Jul 2024 17:21:30 +0800 Subject: [PATCH 143/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E4=BE=9D=E8=B5=96=E7=A7=BB=E8=87=B3=E5=AD=90=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/hzims-big-model/pom.xml | 1 + .../main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java | 4 +++- pom.xml | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index e1ebe29..4075f1f 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -82,6 +82,7 @@ com.baomidou dynamic-datasource-spring-boot-starter + 2.5.6 diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java index 229fc12..ef31b6d 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -25,9 +25,11 @@ public class RequestClientUtil { * @param body 传参body */ public static void postCall(String url, Map body) { + log.info("开始远程调用{}接口",url); HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + log.info("远程调用{}接口结束",url); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new ServiceException("远程调用大模型接口" + url + "失败!"); + throw new ServiceException("远程调用接口" + url + "失败!"); }); } diff --git a/pom.xml b/pom.xml index 31b5875..fee8f9d 100644 --- a/pom.xml +++ b/pom.xml @@ -212,11 +212,6 @@ easypoi-spring-boot-starter ${easpoi.version} - - com.baomidou - dynamic-datasource-spring-boot-starter - 2.5.6 - From 6edb91a9304271094010bbfdc391fc19b58f982b Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 4 Jul 2024 08:19:57 +0800 Subject: [PATCH 144/151] =?UTF-8?q?fix=EF=BC=9A=E9=89=B4=E6=9D=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3requestbody=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/controller/HznlmInteractiveController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 958f103..28b9ad3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -31,17 +31,17 @@ public class HznlmInteractiveController { private final IHznlmInteractiveService interactiveService; - @RequestMapping(value = "/get_auth_data",method = {RequestMethod.GET,RequestMethod.POST}) + @PostMapping(value = "/get_auth_data") @ApiOperation("获取鉴权数据") @ApiOperationSupport(order = 1) - public R> getAuthData(@RequestBody @Valid AuthDataDTO req) { + public R> getAuthData(@RequestBody AuthDataDTO req) { return R.data(interactiveService.getAuthData(req)); } @ApiOperation("解析大模型函数") @ApiOperationSupport(order = 2) @PostMapping("/resolve") - public R resolve(@RequestBody @Valid ModelFunctionReq req) { + public R resolve(@RequestBody ModelFunctionReq req) { return R.data(interactiveService.resolve(req)); } } From c58404a3427363adc15a4cc0db3d933189b99b98 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 5 Jul 2024 11:23:12 +0800 Subject: [PATCH 145/151] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/entity/WhitelistEntity.java | 24 ++++++++++++++ .../whitelist/controller/WhitelistController.java | 38 ++++++++++++++++++++++ .../bigmodel/whitelist/mapper/WhitelistMapper.java | 11 +++++++ .../whitelist/service/WhitelistService.java | 12 +++++++ .../service/impl/WhitelistServiceImpl.java | 18 ++++++++++ 5 files changed, 103 insertions(+) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java new file mode 100644 index 0000000..cc563f0 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/entity/WhitelistEntity.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.bigmodel.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; + +/** + * @author ysj + */ +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_whitelist") +@ApiModel(value = "白名单实体类",description = "大模型白名单") +@Data +public class WhitelistEntity extends TenantEntity { + + @ApiModelProperty(value = "用户Id") + private Long userId; + + @ApiModelProperty(value = "用户登录账号") + private String account; +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java new file mode 100644 index 0000000..7c1d6d6 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/controller/WhitelistController.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.bigmodel.whitelist.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.entity.WhitelistEntity; +import com.hnac.hzims.bigmodel.whitelist.service.WhitelistService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/whitelist") +@Api(value = "白名单用户",tags = "白名单用户") +@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数管理") +@AllArgsConstructor +public class WhitelistController { + + private final WhitelistService whitelistService; + + @PostMapping("/list") + @ApiOperation("查询列表") + @ApiOperationSupport(order = 1) + public R> list(@RequestBody WhitelistEntity entity) { + return R.data(whitelistService.list(Condition.getQueryWrapper(entity))); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java new file mode 100644 index 0000000..c1f87d2 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/mapper/WhitelistMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.bigmodel.whitelist.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.bigmodel.entity.WhitelistEntity; + +/** + * @author ysj + */ +public interface WhitelistMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java new file mode 100644 index 0000000..ceaf79e --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/WhitelistService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.bigmodel.whitelist.service; + +import com.hnac.hzims.bigmodel.entity.WhitelistEntity; +import org.springblade.core.mp.base.BaseService; + + +/** + * @author ysj + */ +public interface WhitelistService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java new file mode 100644 index 0000000..b4b0cb3 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/whitelist/service/impl/WhitelistServiceImpl.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.bigmodel.whitelist.service.impl; + +import com.hnac.hzims.bigmodel.entity.WhitelistEntity; +import com.hnac.hzims.bigmodel.whitelist.mapper.WhitelistMapper; +import com.hnac.hzims.bigmodel.whitelist.service.WhitelistService; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/04/26 11:13 + */ +@Service +@Slf4j +public class WhitelistServiceImpl extends BaseServiceImpl implements WhitelistService { + +} \ No newline at end of file From 2f731cafa02c89bf0baf709a8686287f46273095 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 5 Jul 2024 11:33:49 +0800 Subject: [PATCH 146/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?sql=E6=89=A7=E8=A1=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DataSourceExecuteController.java | 19 ++++--- .../datasource/service/DataSourceService.java | 58 +++++++++++++++++++- .../datasource/service/IDataSourceService.java | 14 ----- .../hnac/hzims/bigmodel/datasource/vo/SqlVO.java | 32 ++++++++++++ .../hzims/bigmodel/datasource/vo/TableAuthVO.java | 28 ++++++++++ .../service/impl/HznlmInteractiveServiceImpl.java | 2 +- .../hzims/bigmodel/interactive/vo/AuthDataVO.java | 4 +- .../controller/TableColumnController.java | 54 +++++++++++++++++++ .../controller/TableInfoController.java | 61 ++++++++++++++++++++++ .../maintenance/entity/DataRecordEntity.java | 17 ++++++ .../maintenance/entity/TableInfoEntity.java | 56 ++++++++++++++++++++ .../maintenance/mapper/TableInfoMapper.java | 12 +++++ .../maintenance/service/TableColumnService.java | 38 ++++++++++++++ .../maintenance/service/TableInfoService.java | 21 ++++++++ 14 files changed, 391 insertions(+), 25 deletions(-) delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java index 84172fe..0542fea 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java @@ -1,11 +1,16 @@ package com.hnac.hzims.bigmodel.datasource.controller; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; +import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; +import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; /** * @Author: huangxing @@ -18,9 +23,11 @@ public class DataSourceExecuteController { private final DataSourceService dataSourceService; - @GetMapping("/executeQuery") - public R executeQuery(String sql,String dataSourceName) { - return R.data(dataSourceService.queryListOnSpecificDataSource(sql,dataSourceName)); + @PostMapping("/executeQuery") + @ApiOperation("执行大模型sql") + @ApiOperationSupport(order = 1) + public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java index d858de3..8509f2b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java @@ -1,14 +1,26 @@ package com.hnac.hzims.bigmodel.datasource.service; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; +import com.hnac.hzims.bigmodel.datasource.vo.TableAuthVO; +import com.hnac.hzims.common.service.UserAuthDataService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * @Author: huangxing @@ -20,12 +32,50 @@ import java.util.regex.Pattern; public class DataSourceService { private final JdbcTemplate jdbcTemplate; + private final UserAuthDataService userAuthDataService; private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); + + public List> queryListOnSpecificDataSource(SqlVO sqlVO) { + // 过滤更新、删除语句 + Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { + throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); + }); + String sql = sqlVO.getSql(); + String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); + List> tempViewList = Lists.newArrayList(); + try { + for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { + // 创建视图语句 + String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", ""); + String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL; + this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName()); + Map viewMap = new HashMap(2); + viewMap.put("datasource",tableAuthVO.getDatasourceName()); + viewMap.put("viewName",viewName); + tempViewList.add(viewMap); + sql = sql.replace(tableAuthVO.getTableName(),viewName); + } + log.info("执行sql:{}",sql); + return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); + } + catch(Exception e) { + log.error("An Error occurred!",e); + throw new ServiceException("sql执行失败!"); + } + finally { + if(CollectionUtil.isNotEmpty(tempViewList)) { + tempViewList.forEach(viewMap -> { + this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource")); + }); + } + } + } + /** - * 指定 + * sql * @param sql * @param dataSourceName * @return @@ -52,11 +102,15 @@ public class DataSourceService { } } + /** + * 过滤更新、删除语法的sql脚本 + * @param sql 待执行sql脚本 + * @return 执行结果 + */ public static boolean isUpdateOrDelete(String sql) { if (sql == null) { return false; } return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); } - } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java deleted file mode 100644 index 1f0e802..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/IDataSourceService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.bigmodel.datasource.service; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/28 14:22 - */ -public interface IDataSourceService { - - List> queryList(String sql); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java new file mode 100644 index 0000000..0765c69 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.bigmodel.datasource.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/05 08:19 + */ +@ApiModel(value = "",description = "") +@Data +@EqualsAndHashCode +public class SqlVO implements Serializable { + + @ApiModelProperty("执行sql") + @NotBlank + private String sql; + + @ApiModelProperty("执行人") + @NotBlank + private String userId; + + @ApiModelProperty("执行sql设计表信息") + private List tableAuthVOList; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java new file mode 100644 index 0000000..711fd43 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.datasource.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/07/04 17:29 + */ +@ApiModel(value = "表鉴权对象",description = "表鉴权对象") +@Data +@EqualsAndHashCode +public class TableAuthVO implements Serializable { + + @ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") + private String auth; + + @ApiModelProperty("数据源名称") + private String datasourceName; + + @ApiModelProperty("数据表名称") + private String tableName; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java index fc0567f..44182a3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java @@ -56,7 +56,7 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { public List getStationAuthData(String userId) { List deptStationDTOs = authenticationService.getStationPermissionsById(userId); - return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getId())).collect(Collectors.toList()); + return deptStationDTOs.stream().map(this::convertStationAuthData).filter(d -> Func.isNotBlank(d.getItemId())).collect(Collectors.toList()); } private AuthDataVO convertStationAuthData(DeptStationDTO req) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java index a74f920..dafd6e7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AuthDataVO.java @@ -19,9 +19,9 @@ import java.io.Serializable; public class AuthDataVO implements Serializable { @ApiModelProperty("数据ID") - private String id; + private String itemId; @ApiModelProperty("数据名称") - private String name; + private String itemName; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java new file mode 100644 index 0000000..79376ff --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.bigmodel.maintenance.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.maintenance.service.TableColumnService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/04 09:28 + */ +@RestController +@RequestMapping("/table/info") +@Api(value = "数据库表、列信息查询管理",tags = "数据库表、列信息查询管理") +@Business(module = BigModelConstants.APP_NAME,value = "数据库表、列信息查询管理",ignore = false) +@AllArgsConstructor +public class TableColumnController { + + private final TableColumnService tableColumnService; + + @ApiOperation("获取数据库") + @ApiOperationSupport(order = 1) + @GetMapping("/getDatabase") + public R>> getDatabase() { + return R.data(tableColumnService.getDatabase()); + } + + @ApiOperation("获取数据库表列表") + @ApiOperationSupport(order = 2) + @GetMapping("/getTables") + public R>> getTables(@RequestParam @ApiParam(value = "数据库名") String database) { + return R.data(tableColumnService.getTables(database)); + } + + @ApiOperation("获取数据库表列列表") + @ApiOperationSupport(order = 3) + @GetMapping("/getColumns") + public R>> getColumns(@RequestParam @ApiParam(value = "数据库名") String database, + @RequestParam @ApiParam(value = "数据库表名") String tableName) { + return R.data(tableColumnService.getColumns(database,tableName)); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java new file mode 100644 index 0000000..4bc0f1d --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableInfoController.java @@ -0,0 +1,61 @@ +package com.hnac.hzims.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; +import com.hnac.hzims.bigmodel.maintenance.service.TableInfoService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:26 + */ +@RestController +@RequestMapping("/tableInfo") +@Api(value = "数据库信息管理",tags = "数据库信息管理") +@AllArgsConstructor +@Business(module = BigModelConstants.APP_NAME,value = "数据库信息管理",ignore = false) +public class TableInfoController { + + private final TableInfoService tableInfoService; + + @PostMapping("/save") + @ApiOperation("保存数据库信息") + @ApiOperationSupport(order = 1) + public R save(@RequestBody @Valid TableInfoEntity req) { + return R.data(tableInfoService.save(req)); + } + + @PostMapping("/update") + @ApiOperation("编辑数据库信息") + @ApiOperationSupport(order = 2) + public R update(@RequestBody TableInfoEntity req) { + return R.data(tableInfoService.updateById(req)); + } + + @GetMapping("/listPage") + @ApiOperation("数据库信息列表查询") + @ApiOperationSupport(order = 3) + public R> listPage(Query query, TableInfoEntity req) { + return R.data(tableInfoService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @DeleteMapping("/removeByIds") + @ApiOperation("删除数据库信息") + @ApiOperationSupport(order = 4) + public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { + return R.status(tableInfoService.removeByIds(Func.toLongList(",",ids))); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java new file mode 100644 index 0000000..af8248c --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DataRecordEntity.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.bigmodel.maintenance.entity; + +import lombok.Data; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:45 + */ +@Data +public class DataRecordEntity extends TenantEntity { + + private String tableId; + + + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java new file mode 100644 index 0000000..9a37d57 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TableInfoEntity.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/04 14:59 + */ +@Data +@TableName("mysql_table_info") +@EqualsAndHashCode +@ApiModel(value = "数据库信息",description = "数据库信息") +public class TableInfoEntity extends TenantEntity implements Serializable { + + @TableField("db_source") + @ApiModelProperty("数据源") + @NotBlank + @QueryField(condition = SqlCondition.LIKE) + private String datasource; + + @TableField("db_name") + @ApiModelProperty("数据库") + @NotBlank + @QueryField(condition = SqlCondition.EQUAL) + private String database; + + @ApiModelProperty("数据库表名") + @NotBlank + @QueryField(condition = SqlCondition.EQUAL) + private String tableName; + + @ApiModelProperty("数据库表描述信息") + @NotBlank + @QueryField(condition = SqlCondition.LIKE) + private String tableDesc; + + @ApiModelProperty("数据库表列信息") + @NotBlank + private String propDesc; + + @ApiModelProperty("举例") + @NotBlank + private String example; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java new file mode 100644 index 0000000..f451a78 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TableInfoMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:25 + */ +public interface TableInfoMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java new file mode 100644 index 0000000..8c31998 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.bigmodel.maintenance.service; + +import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/04 09:29 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class TableColumnService { + + private final DataSourceService dataSourceService; + + public List> getDatabase() { + String sql = "select distinct `table_schema` from `tables` where `table_schema` <> 'information_schema';"; + return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + } + + public List> getTables(String database) { + String sql = "select distinct `table_name` from `tables` where `table_schema` = '" + database + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + } + + public List> getColumns(String database,String tableName) { + String sql = "select `COLUMN_NAME` from `COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java new file mode 100644 index 0000000..e5643d5 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableInfoService.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.bigmodel.maintenance.service; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.bigmodel.maintenance.entity.TableInfoEntity; +import com.hnac.hzims.bigmodel.maintenance.mapper.TableInfoMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/04 15:23 + */ +@Service +@AllArgsConstructor +@Slf4j +@DS("hznlm") +public class TableInfoService extends BaseServiceImpl { + +} From 948000e500b98792a37f177877d06024a4f64c6f Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 5 Jul 2024 14:39:00 +0800 Subject: [PATCH 147/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?sql=E6=89=A7=E8=A1=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/service/DataSourceService.java | 63 +++++++++++++--------- .../controller/HznlmInteractiveController.java | 11 ++++ .../bigmodel/interactive/dto/AuthDataDTO.java | 3 +- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java index 8509f2b..68dd57f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java @@ -45,33 +45,44 @@ public class DataSourceService { }); String sql = sqlVO.getSql(); String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); - List> tempViewList = Lists.newArrayList(); - try { - for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { - // 创建视图语句 - String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", ""); - String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL; - this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName()); - Map viewMap = new HashMap(2); - viewMap.put("datasource",tableAuthVO.getDatasourceName()); - viewMap.put("viewName",viewName); - tempViewList.add(viewMap); - sql = sql.replace(tableAuthVO.getTableName(),viewName); - } - log.info("执行sql:{}",sql); - return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); - } - catch(Exception e) { - log.error("An Error occurred!",e); - throw new ServiceException("sql执行失败!"); - } - finally { - if(CollectionUtil.isNotEmpty(tempViewList)) { - tempViewList.forEach(viewMap -> { - this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource")); - }); - } + for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { + String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; + sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); } + return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); + // 过滤更新、删除语句 +// Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { +// throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); +// }); +// String sql = sqlVO.getSql(); +// String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); +// List> tempViewList = Lists.newArrayList(); +// try { +// for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { +// // 创建视图语句 +// String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", ""); +// String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL; +// this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName()); +// Map viewMap = new HashMap(2); +// viewMap.put("datasource",tableAuthVO.getDatasourceName()); +// viewMap.put("viewName",viewName); +// tempViewList.add(viewMap); +// sql = sql.replace(tableAuthVO.getTableName(),viewName); +// } +// log.info("执行sql:{}",sql); +// return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); +// } +// catch(Exception e) { +// log.error("An Error occurred!",e); +// throw new ServiceException("sql执行失败!"); +// } +// finally { +// if(CollectionUtil.isNotEmpty(tempViewList)) { +// tempViewList.forEach(viewMap -> { +// this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource")); +// }); +// } +// } } /** diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 28b9ad3..1ebbacf 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -2,6 +2,8 @@ package com.hnac.hzims.bigmodel.interactive.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; +import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; +import java.util.Map; /** * @Author: huangxing @@ -30,6 +33,7 @@ import java.util.List; public class HznlmInteractiveController { private final IHznlmInteractiveService interactiveService; + private final DataSourceService dataSourceService; @PostMapping(value = "/get_auth_data") @ApiOperation("获取鉴权数据") @@ -44,4 +48,11 @@ public class HznlmInteractiveController { public R resolve(@RequestBody ModelFunctionReq req) { return R.data(interactiveService.resolve(req)); } + + @PostMapping("/execute_query") + @ApiOperation("执行大模型sql") + @ApiOperationSupport(order = 1) + public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java index 3d4fba5..b891ec0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/AuthDataDTO.java @@ -19,12 +19,11 @@ import java.io.Serializable; @EqualsAndHashCode public class AuthDataDTO implements Serializable { - @JsonProperty("chat_id") + @JsonProperty("chatId") @ApiModelProperty("问答ID,用于获取前端发起问答传入缓存中数据") @NotBlank private String sessionId; - @JsonProperty("user_id") @ApiModelProperty("提问用户ID") @NotBlank private String userId; From 4600e749452dd1ba9462eb10a557bdf0dc740c41 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 9 Jul 2024 18:59:45 +0800 Subject: [PATCH 148/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9E=B6=E6=9E=84=E4=BF=AE=E6=94=B9=20add:?= =?UTF-8?q?=E5=A4=A7=E6=A8=A1=E5=9E=8B=E6=95=B0=E6=8D=AE=E6=BA=90=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/dto/ControlDeviceAuthDTO.java | 23 ++ .../hzims/bigmodel/business/feign/IAuthClient.java | 35 ++ .../hzims/bigmodel/interactive/dto/ControlDTO.java | 36 ++ .../bigmodel/interactive/dto/ControlDeviceDTO.java | 38 ++ .../bigmodel/interactive/req/ModelFunctionReq.java | 15 +- .../hzims/bigmodel/interactive/vo/ExtraVO.java | 6 + .../hzims/bigmodel/business/feign/AuthClient.java | 51 +++ .../business/service/AuthenticationService.java | 124 ++++++ .../datasource/service/DataSourceService.java | 1 + .../interactive/constants/FuncRouteEnum.java | 5 +- .../controller/AnalyseDataController.java | 34 -- .../controller/FontEndInteractiveController.java | 11 +- .../controller/HznlmInteractiveController.java | 10 +- .../controller/InteractiveController.java | 116 ------ .../service/IHznlmInteractiveService.java | 6 +- .../interactive/service/IHznlmInvokeService.java | 6 +- .../interactive/service/IParamsService.java | 15 - .../service/impl/AnalyseDataServiceImpl.java | 13 +- .../service/impl/AuthenticationService.java | 128 ------ .../service/impl/CanvasResolveServiceImpl.java | 14 +- .../service/impl/ExtraResolveStrategyService.java | 259 ------------- .../service/impl/HznlmInteractiveServiceImpl.java | 35 +- .../service/impl/HznlmInvokeServiceImpl.java | 21 +- .../service/impl/InteractiveServiceImpl.java | 430 --------------------- .../service/impl/JumpPageServiceImpl.java | 46 --- .../service/impl/JumpRouteJoinStrategy.java | 3 +- .../interactive/service/impl/ParamStrategy.java | 2 +- .../service/impl/ParamsServiceImpl.java | 36 -- .../service/impl/VideoResolveServiceImpl.java | 10 +- .../controller/DataSourceController.java | 67 ++++ .../controller/TableColumnController.java | 14 +- .../controller/TablePropertyController.java | 66 ++++ .../maintenance/entity/DatasourceEntity.java | 33 ++ .../maintenance/entity/TablePropertyEntity.java | 49 +++ .../maintenance/mapper/DatasourceMapper.java | 12 + .../maintenance/mapper/TablePropertyMapper.java | 11 + .../maintenance/service/DataSourceService.java | 19 + .../maintenance/service/TableColumnService.java | 18 +- .../maintenance/service/TablePropertyService.java | 20 + .../bigmodel/schedule/InteractiveSchedule.java | 201 ---------- .../websocket/handler/InteractiveHandler.java | 15 +- .../src/main/resources/db/2.0.0.sql | 31 ++ 42 files changed, 735 insertions(+), 1350 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java create mode 100644 hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java new file mode 100644 index 0000000..b64fc69 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/ControlDeviceAuthDTO.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.bigmodel.business.dto; + +import com.hnac.hzims.bigmodel.interactive.dto.ControlDeviceDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:43 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "遥控设备鉴权DTO",description = "遥控设备鉴权DTO") +public class ControlDeviceAuthDTO extends ControlDeviceDTO implements Serializable { + + @ApiModelProperty("用户ID") + private String userId; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java new file mode 100644 index 0000000..e4764e7 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.bigmodel.business.feign; + +import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; +import org.springblade.core.tool.api.R; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:11 + * 鉴权接口 - 业务实现 + */ +public interface IAuthClient { + + /** + * 遥控鉴权 + * @param req 遥控信息 + * @return 鉴权结果 + */ + R remoteAuth(ControlDeviceAuthDTO req); + + /** + * 站点鉴权 + * @param userId 用户ID + * @param stationId 站点ID + * @return 鉴权结果 + */ + R stationAuth(String userId,String stationId); + + /** + * 机构鉴权 + * @param userId 用户ID + * @param deptId 站点ID + * @return 鉴权结果 + */ + R deptAuth(String userId,String deptId); +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java new file mode 100644 index 0000000..bc28e67 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDTO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.bigmodel.interactive.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/08 09:20 + */ +@ApiModel("设备控制DTO") +@Data +@EqualsAndHashCode +public class ControlDTO implements Serializable { + + @ApiModelProperty("用户ID") + @NotBlank + private String userId; + + @ApiModelProperty("会话ID") + @NotBlank + private String chatId; + + @ApiModelProperty("value目前有值、'大' '小' '最大' '最小' ‘开’ '关'") + private String value; + + @ApiModelProperty("遥控点位") + private List yks; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java new file mode 100644 index 0000000..40e3516 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/dto/ControlDeviceDTO.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.bigmodel.interactive.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/08 16:22 + */ +@Data +@ApiModel(value = "",description = "") +@EqualsAndHashCode +public class ControlDeviceDTO implements Serializable { + + @ApiModelProperty(value = "站点ID") + private String stationId; + + @ApiModelProperty(value = "设备ID") + @NotBlank + private String deviceId; + + @ApiModelProperty(value = "控制ID") + @NotBlank + private String itemId; + + @ApiModelProperty(value = "控制名称") + private String itemName; + + @ApiModelProperty(value = "遥控类型,平台、业务") + @NotBlank + private String type; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java index a1fe20c..3977291 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/req/ModelFunctionReq.java @@ -16,15 +16,16 @@ import java.util.Map; @ApiModel("大模型响应内容") public class ModelFunctionReq implements Serializable { - @ApiModelProperty("类型") - private String type; - - @JSONField(name = "function_name") @ApiModelProperty("函数标识") - private String functionName; + private String func; + + @ApiModelProperty("会话ID") + private String chatId; + + @ApiModelProperty("用户ID") + private String userId; - @JSONField(name = "function_args") @ApiModelProperty("函数参数") - private Map functionArgs; + private Map item; } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index d01b6e6..c864829 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -1,6 +1,8 @@ package com.hnac.hzims.bigmodel.interactive.vo; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -21,9 +23,11 @@ public class ExtraVO implements Serializable { private String type; @ApiModelProperty("若为弹窗,则返回路由") + @JsonInclude(JsonInclude.Include.NON_NULL) private String route; @ApiModelProperty("链接显示文字") + @JsonInclude(JsonInclude.Include.NON_NULL) private String label; @ApiModelProperty("函数编号") @@ -33,12 +37,14 @@ public class ExtraVO implements Serializable { private boolean isImmediatelyJump = false; @ApiModelProperty("附带参数") + @JsonInclude(JsonInclude.Include.NON_NULL) private Map params; @ApiModelProperty("是否为特殊函数") private boolean isSpecial; @ApiModelProperty("选项") + @JsonInclude(JsonInclude.Include.NON_NULL) private List selection; @JSONField(name = "agent_name") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java new file mode 100644 index 0000000..91ec809 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java @@ -0,0 +1,51 @@ +package com.hnac.hzims.bigmodel.business.feign; + +import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; +import com.hnac.hzims.bigmodel.business.service.AuthenticationService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.DeptStationDTO; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Optional; + +/** + * @Author: huangxing + * @Date: 2024/07/09 09:31 + */ +@Component +@AllArgsConstructor +@Slf4j +public class AuthClient implements IAuthClient { + + private final AuthenticationService authenticationService; + + @Override + public R remoteAuth(ControlDeviceAuthDTO req) { + // 若站点不为空 则对站点进行鉴权 + if(StringUtil.isNotBlank(req.getStationId())) { + if(!authenticationService.stationAuthentication(req.getStationId(), req.getUserId())) { + return R.fail("站点鉴权失败!"); + } + } + if("业务".equals(req.getType())) { + + } + return R.success("鉴权成功"); + } + + @Override + public R stationAuth(String userId, String stationId) { + return R.status(authenticationService.stationAuthentication(stationId,userId)); + } + + @Override + public R deptAuth(String userId, String deptId) { + List deptStationDTOList = authenticationService.getStationPermissionsById(userId); + boolean result = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).anyMatch(d -> Long.valueOf(deptId).equals(d)); + return R.status(result); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java new file mode 100644 index 0000000..f8e23a0 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java @@ -0,0 +1,124 @@ +package com.hnac.hzims.bigmodel.business.service; + +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.entity.FunctionEntity; +import com.hnac.hzims.bigmodel.function.service.IFunctionService; +import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; +import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; +import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +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.dto.DeptStationDTO; +import org.springblade.system.entity.CtrlAuth; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.IRemoteClient; +import org.springblade.system.user.feign.IUserClient; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/05/21 16:10 + */ +@Service +@AllArgsConstructor +public class AuthenticationService { + + private final IDeptClient deptClient; + private final IFunctionService functionService; + private final IUserClient userClient; + private final ProjectClient projectClient; + private final IRemoteClient remoteClient; + private final RedisTemplate redisTemplate; + + /** + * 站点鉴权 + * @param stationId 站点ID + * @param userId 用户ID + */ + public Boolean stationAuthentication(String stationId, String userId) { + List deptStationDTOList = this.getStationPermissionsById(userId); + return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(s -> stationId.equals(s)); + } + + /** + * 菜单鉴权 + * @param userId 用户ID + * @param func 函数编号 + */ + public void menuAuthentication(String userId, String func) { + FunctionEntity function = functionService.getFunctionByCode(func); + if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { + R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); + Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { + throw new ServiceException("人员菜单鉴权失败!"); + }); + } + } + + /** + * 遥控鉴权 + * @param stationId 站点ID + * @param userId 用户ID + */ + public void remoteAuthentication(String stationId, String userId,String sessionId) { + // 查询数据平台站点是否可被遥控 + Result> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); + Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { + throw new ServiceException("未查询到站点,鉴权失败!"); + }); + ProjectVO project = projectR.getData().get(0); + if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { + // 不允许发送遥控 + throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); + } + else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { + // 运行发送遥控并且需要校验权限 + R> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); + Assert.isTrue(ctrlAuthR.isSuccess(),() -> { + throw new ServiceException("该站点未设置鉴权用户,校验失败!"); + }); + List ctrlAuthList = ctrlAuthR.getData(); + Optional authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); + Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { + throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); + }); + CtrlAuth ctrlAuth = authOptional.get(); + // 如限制机器发送遥控指令 + if(ctrlAuth.getIsLimitMachine().intValue() == 1) { + SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); + Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); + String machineCode = sessionContent.getMachineCode(); + Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { + throw new ServiceException("获取问题机器码失败,校验不通过!"); + }); + Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { + throw new ServiceException("站点校验码校验失败,校验不通过!"); + }); + } + } + } + + public List getStationPermissionsById(String userId) { + R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + return deptSattionR.getData(); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java index 68dd57f..5cb211f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java @@ -49,6 +49,7 @@ public class DataSourceService { String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); } + log.info("执行sql:{}",sql); return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); // 过滤更新、删除语句 // Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { 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 c3baac3..cdd2857 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 @@ -24,16 +24,17 @@ public enum FuncRouteEnum { SHOW_PARAM("result_record","设备参数查询", FunctionConstants.TypeEnum.PARAMS), CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE), HISTORY_DATA("history_data","查询历史数据",FunctionConstants.TypeEnum.CHART), + CONTROL_DEVICE("control_device","设备控制",FunctionConstants.TypeEnum.PARAMS) ; @Getter - private String funcCode; + private String func; @Getter private String funcName; @Getter private FunctionConstants.TypeEnum type; public static FuncRouteEnum getEnumByFuncCode(String funcCode) { - Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFuncCode())).findFirst(); + Optional FuncRoute = Arrays.stream(FuncRouteEnum.class.getEnumConstants()).filter(e -> funcCode.equals(e.getFunc())).findFirst(); return FuncRoute.orElse(null); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java deleted file mode 100644 index d09637f..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/AnalyseDataController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; -import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @Author: huangxing - * @Date: 2024/05/29 09:22 - */ -@RequestMapping("/analyse/data") -@AllArgsConstructor -@Api(value = "数据查询管理",tags = "数据查询管理") -@RestController -@Deprecated -public class AnalyseDataController { - - private final IAnalyseDataService analyseDataService; - - @GetMapping("/getHistoryData") - @ApiOperation("获取历史数据") - @ApiOperationSupport(order = 1) - public R getHistoryData(@Validated HistoryDataSearchVO searchVO) { - return R.data(analyseDataService.getHistoryData(searchVO)); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java index 9d0afe8..ac3789b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/FontEndInteractiveController.java @@ -10,6 +10,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.IResultCode; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -50,7 +51,7 @@ public class FontEndInteractiveController { @ApiOperation("获取热点问题") @ApiOperationSupport(order = 3) @GetMapping("/hotQuestions") - public R> hotQuestions() { + public R hotQuestions() { return R.data(hznlmInvokeService.hotQuestions()); } @@ -60,4 +61,12 @@ public class FontEndInteractiveController { public R getSessionId() { return R.data(IdWorker.get32UUID()); } + + @ApiOperation("中断当前的问答") + @ApiOperationSupport(order = 5) + @GetMapping("/interruptSession") + public R interruptSession(@RequestParam(value = "id") String sessionId) { + hznlmInvokeService.askAbort(sessionId); + return R.success("操作成功!"); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 1ebbacf..2e8843e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -5,6 +5,7 @@ import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; @@ -51,8 +52,15 @@ public class HznlmInteractiveController { @PostMapping("/execute_query") @ApiOperation("执行大模型sql") - @ApiOperationSupport(order = 1) + @ApiOperationSupport(order = 3) public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); } + + @PostMapping("/control_device") + @ApiOperation("控制设备") + @ApiOperationSupport(order = 4) + public R controlDevice(@RequestBody @Valid ControlDTO req) { + return R.data(interactiveService.controlDevice(req)); + } } 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 deleted file mode 100644 index 35537ee..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.controller; - -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; -import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO; -import com.hnac.hzinfo.log.annotation.Business; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; -import org.springframework.web.bind.annotation.*; - -import java.text.DecimalFormat; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/04/26 14:51 - */ -@RestController -@AllArgsConstructor -@Api(value = "FDP大模型交互层",tags = "FDP大模型交互层") -@RequestMapping("/interactive") -@Business(module = BigModelConstants.MODULE_NAME,value = "FDP大模型交互层") -@Deprecated -public class InteractiveController { - - private final IInteractiveService interactiveService; - - @ApiOperation("解析大模型函数") - @ApiOperationSupport(order = 1) - @PostMapping("/resolve") - public R resolve(@RequestBody ModelFunctionReq req) { - return interactiveService.resolve(req); - } - - @ApiOperation("提问") - @ApiOperationSupport(order = 2) - @GetMapping("/ask") - @Deprecated - public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) { - return interactiveService.ask(question, sessionId, userId); - } - - @ApiOperation("站点、菜单鉴权") - @ApiOperationSupport(order = 3) - @Deprecated - @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 func, - @RequestParam(required = false) @ApiParam("会话ID")String askId) { - return R.status(interactiveService.authentication(stationId,userId,func,askId)); - } - - @ApiOperation("获取问答sessionId") - @ApiOperationSupport(order = 4) - @GetMapping("/getSessionId") - public R getSessionId() { - return R.data(IdWorker.get32UUID()); - } - - @ApiOperation("删除对话sessionId") - @ApiOperationSupport(order = 5) - @GetMapping("/removeSessionId") - @Deprecated - public R removeSessionId(@RequestParam(value = "id") String sessionId) { - return R.data(interactiveService.removeSessionId(sessionId)); - } - - @ApiOperation("下发遥控指令") - @ApiOperationSupport(order = 6) - @PostMapping("/sendRemoteControl") - public R sendRemoteControl(@RequestBody ControlDTO operate) { - return interactiveService.sendRemoteControl(operate); - } - - @ApiOperation("解析接入站点数量") - @ApiOperationSupport(order = 7) - @PostMapping("/resolveStations") - public R resolveStations(@RequestBody StationSearchVO req) { - return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType())); - } - - @ApiOperation("站点发电量") - @ApiOperationSupport(order = 7) - @RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST}) - public R generation(@RequestParam @ApiParam("站点编号") String stationId, - @RequestParam @ApiParam("开始时间") String startTime, - @RequestParam @ApiParam("结束时间")String endTime) { - double generate = interactiveService.generation(stationId,startTime,endTime); - DecimalFormat format = new DecimalFormat("0.00"); - return R.data(format.format(generate) + "kWh"); - } - - @ApiOperation("获取热点问题") - @ApiOperationSupport(order = 8) - @GetMapping("/hotQuestions") - @Deprecated - public R hotQuestions() { - try{ - List questions = interactiveService.hotQuestions(); - return R.data(questions); - } - catch (Exception e) { - e.printStackTrace(); - return R.data(Lists.newArrayList()); - } - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java index ec26387..c9aed6b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInteractiveService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; @@ -16,7 +17,10 @@ import java.util.List; */ public interface IHznlmInteractiveService { - List getAuthData(@RequestBody @Valid AuthDataDTO req); + List getAuthData(AuthDataDTO req); ExtraVO resolve(ModelFunctionReq req); + + ExtraVO controlDevice(ControlDTO req); + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java index 6cfa306..59c2089 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java @@ -58,6 +58,10 @@ public interface IHznlmInvokeService { */ List getAnswerBySessionIds(String sessionIds); - + /** + * 中断当前的问答 + * @param sessionId 会话ID + */ + void askAbort(String sessionId); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java deleted file mode 100644 index f39a0fb..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IParamsService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.entity.FunctionEntity; - -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/05/09 08:50 - */ -@Deprecated -public interface IParamsService { - String dealJumpTypeFunction(FunctionEntity function, Map args); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 418f66c..ae74c7f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -1,6 +1,5 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; -import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.data.service.HistoryDataService; import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; @@ -10,23 +9,13 @@ import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,7 +46,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { searchVO.setDataType(adapterDate.getDateType()); ExtraVO extraVO = new ExtraVO(); extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); - extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.HISTORY_DATA.getFunc()); Map params = new HashMap<>(1); Result reductionDataVOR = historyDataService.getPolymerizationData(searchVO); String label; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java deleted file mode 100644 index f34088b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AuthenticationService.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; -import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; -import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; -import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; -import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; -import lombok.AllArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -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.dto.DeptStationDTO; -import org.springblade.system.entity.CtrlAuth; -import org.springblade.system.feign.IDeptClient; -import org.springblade.system.feign.IRemoteClient; -import org.springblade.system.user.feign.IUserClient; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/05/21 16:10 - */ -@Service -@AllArgsConstructor -public class AuthenticationService { - - private final IDeptClient deptClient; - private final IFunctionService functionService; - private final IUserClient userClient; - private final ProjectClient projectClient; - private final IRemoteClient remoteClient; - private final RedisTemplate redisTemplate; - - /** - * 站点鉴权 - * @param stationId 站点ID - * @param userId 用户ID - */ - public void stationAuthentication(String stationId, String userId) { - List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) - .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); - Assert.isTrue(stations.contains(stationId),() -> { - throw new ServiceException("人员站点鉴权失败!"); - }); - } - - /** - * 菜单鉴权 - * @param userId 用户ID - * @param func 函数编号 - */ - public void menuAuthentication(String userId, String func) { - FunctionEntity function = functionService.getFunctionByCode(func); - if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { - R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); - Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { - throw new ServiceException("人员菜单鉴权失败!"); - }); - } - } - - /** - * 遥控鉴权 - * @param stationId 站点ID - * @param userId 用户ID - */ - public void remoteAuthentication(String stationId, String userId,String sessionId) { - // 查询数据平台站点是否可被遥控 - Result> projectR = projectClient.getProjectIds(Lists.newArrayList(stationId)); - Assert.isTrue(projectR.isSuccess() && CollectionUtil.isNotEmpty(projectR.getData()) && projectR.getData().size() == 1,() -> { - throw new ServiceException("未查询到站点,鉴权失败!"); - }); - ProjectVO project = projectR.getData().get(0); - if(ProjectRemoteTypeEnum.NOT_ALLOW.getCtrlType().equals(project.getCtrlType())) { - // 不允许发送遥控 - throw new ServiceException("该站点不允许发送遥控指令,校验失败!"); - } - else if(ProjectRemoteTypeEnum.VALID.getCtrlType().equals(project.getCtrlType())) { - // 运行发送遥控并且需要校验权限 - R> ctrlAuthR = remoteClient.getCtrlAuth(Optional.ofNullable(userId).filter(StringUtil::isNotBlank).map(Long::parseLong).orElse(null)); - Assert.isTrue(ctrlAuthR.isSuccess(),() -> { - throw new ServiceException("该站点未设置鉴权用户,校验失败!"); - }); - List ctrlAuthList = ctrlAuthR.getData(); - Optional authOptional = ctrlAuthList.stream().filter(c -> c.getProjectId().equals(stationId)).findFirst(); - Assert.isTrue(authOptional.isPresent() && Func.isNotEmpty(authOptional.get().getIsLimitMachine()), () -> { - throw new ServiceException("该用户不存在相应站点权限,校验不通过!"); - }); - CtrlAuth ctrlAuth = authOptional.get(); - // 如限制机器发送遥控指令 - if(ctrlAuth.getIsLimitMachine().intValue() == 1) { - SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); - Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { - throw new ServiceException("获取问题机器码失败,校验不通过!"); - }); - String machineCode = sessionContent.getMachineCode(); - Assert.isTrue(StringUtil.isNotBlank(machineCode) && Func.isNotEmpty(machineCode) ,() -> { - throw new ServiceException("获取问题机器码失败,校验不通过!"); - }); - Assert.isTrue(machineCode.equals(ctrlAuth.getMachineCode()),() -> { - throw new ServiceException("站点校验码校验失败,校验不通过!"); - }); - } - } - - } - - public List getStationPermissionsById(String userId) { - R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); - Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { - throw new ServiceException("获取人员站点权限失败!"); - }); - return deptSattionR.getData(); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java index 3016a6b..b54712b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -7,13 +7,10 @@ import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; -import lombok.RequiredArgsConstructor; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; @@ -40,24 +37,21 @@ public class CanvasResolveServiceImpl implements IResolveService { @Override public ExtraVO resolve(ModelFunctionReq req) { - Map args = req.getFunctionArgs(); - String id = args.get("id"); - String name = args.get("name"); + Map args = req.getItem(); + String id = args.get("itemId"); + String name = args.get("itemName"); Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req)); throw new ServiceException("解析传参错误,缺少必要参数video_id"); }); return this.resolve(id); -// ExtraVO extra = this.resolve(id); -// String message = "已成功打开" + name + ";"; -// return new ResolveResultVO(message,extra); } @Override public ExtraVO resolve(String id) { ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); // 将ID解析为 diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java deleted file mode 100644 index 05f54db..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; -import com.hnac.hzims.bigmodel.interactive.service.IAnalyseDataService; -import com.hnac.hzims.bigmodel.interactive.vo.*; -import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; -import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; -import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; -import com.xxl.job.core.log.XxlJobLogger; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; -import org.springframework.stereotype.Service; - -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/05/08 16:19 - */ -@Service -@AllArgsConstructor -@Deprecated -public class ExtraResolveStrategyService { - - public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss.SSS"; - - public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN_DATETIME); - - private final IStationClient stationClient; - private final IStationVideoTypeClient videoTypeClient; - private final JumpRouteJoinStrategy jumpRouteJoinStrategy; - private final DeviceClient deviceClient; - private final IAnalyseDataService analyseDataService; - - /** - * 解析DFP返回extra - * @param extraStr DFP返回extra - * @return 与前端交互extra - */ - public ExtraVO resolve(String extraStr) { - JSONObject extra = JSONObject.parseObject(extraStr); - String functionCode = Optional.ofNullable(extra.get("func")).map(String::valueOf).orElse(""); - if(StringUtil.isNotBlank(functionCode)) { - XxlJobLogger.log("函数编号为:" + functionCode); - FuncRouteEnum funcRouteEnum = FuncRouteEnum.getEnumByFuncCode(functionCode); - if(Func.isNotEmpty(funcRouteEnum)) { - switch (funcRouteEnum) { - case DIAGNOSE: - return this.resolveDiagnose(extra); - case CHOOSE_VIDEO: - case CHOOSE_CANVAS: - case CHOOSE_STATION: - case CHOOSE_FAULT: - case CHOOSE_YC: - case CHOOSE_YK: - return this.resolveChooseSelection(extra,funcRouteEnum); - case CONFIRM_YK: - return this.resolveConfirmRemote(extra); - case SHOW_PARAM: - return this.resolveShowParam(extra); - default: - break; - } - } - } - else if(extra.containsKey("extra")){ - return extra.getObject("extra",ExtraVO.class); - } - return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); - } - - private ExtraVO resolveChooseSelection(JSONObject extra,FuncRouteEnum funcRouteEnum) { - ExtraVO result = new ExtraVO(); - JSONArray selections = JSONArray.parseArray(JSON.toJSONString(extra.get("data"))); - result.setFunc(funcRouteEnum.getFuncCode()); - result.setSpecial(true); - result.setSelection(selections); - result.setType(funcRouteEnum.getType().getType()); - return result; - } - -// private ExtraVO resolveChooseYc(JSONObject extra) { -// ExtraVO result = new ExtraVO(); -// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); -// if(data.containsKey("yks")) { -// -// -// List attrs = JSONArray.parseArray(JSON.toJSONString(data.get("yks")), AttrSelectionVO.class); -// result.setSelection(attrs); -// } -// result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode()); -// result.setSpecial(true); -// result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); -// return result; -// } - - private ExtraVO resolveShowParam(Map extra) { - DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); - if(Func.isNotEmpty(data)) { - if(Func.isNotEmpty(data.getReal())) { - if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { - RealDataVO real = data.getReal(); - Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); - real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); - } - } - if(Func.isNotEmpty(data.getItem()) && StringUtil.isNotBlank(data.getMethod())) { - if(SearchTypeEnum.HISTORY.getSearchType().equals(data.getType()) && Func.isNotEmpty(data.getItem())) { - DataItemVO item = data.getItem(); - HistoryDataSearchVO searchVO = new HistoryDataSearchVO(); - searchVO.setDataType(data.getDataType()); - searchVO.setAttrName(item.getAttrName()); - searchVO.setDeviceCode(item.getDeviceId()); - searchVO.setDeviceName(item.getDeviceName()); - searchVO.setStationName(item.getProjectName()); - searchVO.setMethod(data.getMethod()); - searchVO.setSignage(item.getSignage()); - searchVO.setStartTime(data.getStartTime()); - searchVO.setEndTime(data.getEndTime()); - return analyseDataService.getHistoryData(searchVO); - } - } - } - ExtraVO result = new ExtraVO(); - result.setFunc(FuncRouteEnum.SHOW_PARAM.getFuncCode()); - result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); - Map param = new HashMap(1); - param.put("data", data); - result.setParams(param); - return result; - } - - @Deprecated - private ExtraVO resolveConfirmRemote(Map extra) { - ExtraVO result = new ExtraVO(); - RemoteParamVO remoteParam = JSONObject.parseObject(JSON.toJSONString(extra.get("data")), RemoteParamVO.class); - result.setFunc(FuncRouteEnum.CONFIRM_YK.getFuncCode()); - result.setType(FuncRouteEnum.CONFIRM_YK.getType().getType()); - R funcVOR = deviceClient.getFuncById(remoteParam.getFuncId()); - if(funcVOR.isSuccess()) { - Map param = new HashMap(); - param.put("control",funcVOR.getData()); - param.put("deviceName",remoteParam.getDeviceName()); - param.put("projectName",remoteParam.getProjectName()); - param.put("deviceCode",remoteParam.getDeviceId()); - param.put("value",remoteParam.getValue()); - result.setParams(param); - } - return result; - } - -// private ExtraVO resolveChooseFault(Map extra) { -// ExtraVO result = new ExtraVO(); -// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); -// if(data.containsKey("faults")) { -// List faults = JSONArray.parseArray(JSON.toJSONString(data.get("faults")), FaultSelectionVO.class); -// result.setSelection(faults); -// } -// result.setFuncCode(FuncRouteEnum.CHOOSE_FAULT.getFuncCode()); -// result.setSpecial(true); -// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); -// return result; -// } - - private ExtraVO resolveDiagnose(Map extra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - Map params = new HashMap<>(5); - params.put("faultId",data.getString("fault_id")); - params.put("name",data.getString("fault_name")); - params.put("station",data.getString("station_id")); - params.put("fdpDeviceName",data.getString("device_name")); - params.put("fdpOrd",data.getString("ord")); - result.setParams(params); - result.setFunc(FuncRouteEnum.DIAGNOSE.getFuncCode()); - result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); - return result; - } - - /** - * - * @param extra - * @return - */ -// private ExtraVO resolveChooseStation(Map extra) { -// ExtraVO result = new ExtraVO(); -// JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); -// if(data.containsKey("stations")) { -// List stations = JSONArray.parseArray(JSON.toJSONString(data.get("stations")), String.class); -// List selectionList = stations.stream().map(stationId -> { -// StationSelectionVO selectionVO = new StationSelectionVO(); -// R stationR = stationClient.getStationByCode(stationId); -// if (stationR.isSuccess() && Func.isNotEmpty(stationR.getData())) { -// selectionVO.setId(stationId); -// selectionVO.setName(stationR.getData().getName()); -// } -// return selectionVO; -// }).collect(Collectors.toList()); -// result.setSelection(selectionList); -// result.setFuncCode(FuncRouteEnum.CHOOSE_STATION.getFuncCode()); -// result.setSpecial(true); -// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); -// } -// result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); -// return result; -// } - - private ExtraVO resolveChooseVideo(Map extra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - if(data.containsKey("videos")) { - List videoIds = JSONArray.parseArray(JSON.toJSONString(data.get("videos")), JSONObject.class); - List selections = videoIds.stream().map(video -> { - R videoR = videoTypeClient.getById(Long.valueOf(video.getString("id"))); - VideoSelectionVO selectionVO = new VideoSelectionVO(); - if (videoR.isSuccess() && Func.isNotEmpty(videoR.getData())) { - selectionVO.setId(video.getString("id")); - selectionVO.setName(videoR.getData().getName()); - } - return selectionVO; - }).collect(Collectors.toList()); - result.setFunc(FuncRouteEnum.CHOOSE_VIDEO.getFuncCode()); - result.setSpecial(true); - result.setSelection(selections); - } - result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); - return result; - } - - private ExtraVO resolveChooseScada(Map extra) { - ExtraVO result = new ExtraVO(); - JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); - if(data.containsKey("canvases")) { - List canvases = JSONArray.parseArray(JSON.toJSONString(data.get("canvases")), JSONObject.class); - List selections = canvases.stream().map(canvas -> { - ScadaSelectionVO selectionVO = new ScadaSelectionVO(); - Map resolve = jumpRouteJoinStrategy.resolve(canvas.getString("id"), JumpRouteJoinStrategy.SCADA_PARAMS_SOLVE); - selectionVO.setId(canvas.getString("id")); - selectionVO.setName(resolve.get("name")); - return selectionVO; - }).collect(Collectors.toList()); - result.setFunc(FuncRouteEnum.CHOOSE_CANVAS.getFuncCode()); - result.setSpecial(true); - result.setSelection(selections); - } - result.setType(FunctionConstants.TypeEnum.CHOOSE.getType()); - return result; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java index 44182a3..b22a790 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java @@ -1,22 +1,32 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; +import com.hnac.hzims.bigmodel.business.feign.IAuthClient; +import com.hnac.hzims.bigmodel.business.service.AuthenticationService; import com.hnac.hzims.bigmodel.interactive.constants.DataAuthTypeEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; +import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import groovy.util.logging.Slf4j; import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.system.dto.DeptStationDTO; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; /** @@ -29,6 +39,7 @@ import java.util.stream.Collectors; public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { private final AuthenticationService authenticationService; + private final IAuthClient authClient; @Override public List getAuthData(AuthDataDTO req) { @@ -45,10 +56,30 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService { @Override public ExtraVO resolve(ModelFunctionReq req) { - IResolveService resolveService = ResolveFactory.getResolveService(req.getFunctionName()); + IResolveService resolveService = ResolveFactory.getResolveService(req.getFunc()); return resolveService.resolve(req); } + @Override + public ExtraVO controlDevice(ControlDTO req) { + ExtraVO result = new ExtraVO(); + Optional optional = req.getYks().stream().map(controlDeviceDTO -> { + ControlDeviceAuthDTO deviceAuthDTO = BeanUtil.copy(controlDeviceDTO, ControlDeviceAuthDTO.class); + deviceAuthDTO.setUserId(req.getUserId()); + return deviceAuthDTO; + }).filter(d -> authClient.remoteAuth(d).isSuccess()).findFirst(); + Assert.isTrue(optional.isPresent(),() -> { + throw new ServiceException("鉴权失败!!"); + }); + // 封装返回的extra + result.setFunc(FuncRouteEnum.CONTROL_DEVICE.getFunc()); + result.setType(FuncRouteEnum.CONTROL_DEVICE.getType().getType()); + Map params = BeanUtil.toMap(optional.get()); + params.put("value", req.getValue()); + result.setParams(params); + return result; + } + public List getDeptAuthData(String userId) { List deptStationDTOs = authenticationService.getStationPermissionsById(userId); return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index db48d34..a910692 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -1,33 +1,24 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.TypeReference; import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.business.service.AuthenticationService; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.manager.SessionRedisManager; import com.hnac.hzims.bigmodel.utils.RequestClientUtil; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import com.xxl.job.core.log.XxlJobLogger; -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.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.dto.DeptStationDTO; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; -import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -90,14 +81,18 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void removeSessionId(String sessionId) { - Map params = new HashMap<>(); - params.put("id",sessionId); - RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params); + this.askAbort(sessionId); // 移除内存sessionId InteractiveSessionManager.SESSION_POOL.remove(sessionId); sessionRedisManager.removeSessionId(sessionId); } + public void askAbort(String sessionId) { + Map params = new HashMap<>(); + params.put("id",sessionId); + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAskAbort(), params); + } + @Override public List hotQuestions() { try { 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 deleted file mode 100644 index a5eff60..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ /dev/null @@ -1,430 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum; -import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; -import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; -import com.hnac.hzims.bigmodel.interactive.service.IParamsService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzims.equipment.feign.IEmInfoClient; - import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; -import com.hnac.hzims.equipment.vo.RideDeviceVo; -import com.hnac.hzims.operational.fill.feign.IGenerateClient; -import com.hnac.hzims.operational.main.constant.HomePageConstant; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; -import com.xxl.job.core.log.XxlJobLogger; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.MapUtils; -import org.apache.poi.ss.formula.functions.T; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.log.logger.BladeLogger; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; -import org.springblade.system.dto.ControlDTO; -import org.springblade.system.dto.DeptStationDTO; -import org.springblade.system.feign.IDeptClient; -import org.springblade.system.feign.IRemoteClient; -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; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -import javax.servlet.http.HttpServletResponse; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.concurrent.*; -import java.util.stream.Collectors; - -import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.HZIMS_BIGMODEL_ASK_KEY; - -/** - * @Author: huangxing - * @Date: 2024/04/26 14:51 - */ -@Service -@Slf4j -@RequiredArgsConstructor -@Deprecated -public class InteractiveServiceImpl implements IInteractiveService { - - private final BladeLogger logger; - - private final IEmInfoClient deviceClient; - - private final IRemoteClient remoteClient; - - private final IStationClient stationClient; - - private final IGenerateClient generateClient; - - private final IJumpPageService jumpPageService; - - private final IParamsService paramsService; - - private final IFunctionService functionService; - - private final BigModelInvokeUrl bigModelInvokeUrl; - - private final AuthenticationService authenticationService; - - private final RedisTemplate redisTemplate; - - private final IAnalyseDataSearchClient analyseDataSearchClient; - - private final ExtraResolveStrategyService extraResolveStrategyService; - - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); - - @Value("${fdp.host}") - private String fdpHost; - - @Override - public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) { - ExtraVO extraVO = new ExtraVO(); - extraVO.setType(TypeEnum.PARAMS.getType()); - extraVO.setFunc("stations_num"); - String label; - SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) { - label = String.format("自%s到%s时间为止,",startTime,endTime); - } - else { - startTime = null; - endTime = null; - label = "目前"; - } - R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType()); - Assert.isTrue(stationListR.isSuccess(),() -> { - throw new ServiceException("获取接入站点数量失败!"); - }); - Map params = new HashMap<>(); - params.put("searchStationType",stationTypeEnum.getSearchStationType()); - params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size())); - params.put("startTime",startTime); - params.put("endTime",endTime); - extraVO.setParams(params); - return extraVO; - } - - @Override - public R resolve(ModelFunctionReq req) { - logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); - FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); - TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); - if(Func.isEmpty(typeEnum)) { - throw new ServiceException("函数解析失败!"); - } - switch (typeEnum) { - // 页面跳转 - case JUMP: - String jumpExtra = jumpPageService.dealJumpTypeFunction(function, req.getFunctionArgs()); - Assert.isTrue(StringUtil.isNotBlank(jumpExtra) && Func.isNotEmpty(jumpExtra), () -> { - throw new ServiceException("解析" + function.getName() + "函数失败!"); - }); - return R.data(jumpExtra); - case PARAMS: - String paramExtra = paramsService.dealJumpTypeFunction(function, req.getFunctionArgs()); - return R.data(paramExtra); - default: - throw new ServiceException("函数解析失败!"); - } - } - - @Override - public R ask(String question,String sessionId,String userId) { - Map params = new HashMap<>(); - params.put("id",sessionId); - params.put("userid", userId); - params.put("query",question); - params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) - .body(JSON.toJSONString(params)).execute(); - logger.info("interactive:ask","问答传参为:" + JSON.toJSONString(params) + "结果为:" + response.body()); - if(response.getStatus() != HttpServletResponse.SC_OK) { - log.error("远程调用大模型【发起问答】接口失败!"); - return R.fail("远程调用大模型【发起问答】接口失败!"); - } - this.addQuestionSessionId(sessionId); - return R.success("消息发送成功"); - } - - private void addQuestionSessionId(String sessionId) { - redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); - } - - @Override - public R specialAsk(String sessionId, String userId, Map extra) { - Map params = new HashMap<>(); - params.put("id",sessionId); - params.put("userid", userId); - params.put("extra",extra); - params.put("stationids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids",authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).map(String::valueOf).toArray()); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk()) - .body(JSON.toJSONString(params)).execute(); - if(response.getStatus() != HttpServletResponse.SC_OK) { - log.error("远程调用大模型【发起特殊问答】接口失败!"); - return R.fail("远程调用大模型【发起特殊问答】接口失败!"); - } - this.addQuestionSessionId(sessionId); - return R.success("消息发送成功"); - } - - @Override - public List hotQuestions() { - String url = fdpHost + bigModelInvokeUrl.getHotQuestion(); - return this.postCall(url,null,List.class); - } - - /** - * 远程调用http接口 - * @param url 接口url - * @param body 传参 - * @param resultT 结果解析对象 - * @return 结果 - * @param 结果解析对象类型 - */ - public T postCall(String url,Map body,Class resultT) { - HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - log.error("远程调用大模型接口" + url + "失败!"); - throw new ServiceException("远程调用大模型接口" + url + "失败!"); - }); - return JSONObject.parseObject(response.body(), resultT); - } - - @Override - public void updateVideo(Map request) { - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo()) - .body(JSON.toJSONString(request)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new ServiceException("远程调用大模型【更新实时监控】接口失败!"); - }); - } - - @Override - public Boolean updateCanvas(Map request) { - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateCanvas()) - .body(JSON.toJSONString(request)).execute(); - if (response.getStatus() == HttpServletResponse.SC_OK) { - return true; - } - log.error("远程调用大模型【更新实时画面】接口失败!"); - return false; - } - - @Override - public void updateFault(Map request) { - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateFault()) - .body(JSON.toJSONString(request)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new ServiceException("远程调用大模型【更新故障列表】接口失败!"); - }); - } - - @Override - public List getAnswerBySessionIds(String sessionIds) { - Map params = new HashMap<>(); - params.put("ids",Func.toStrList(",",sessionIds).toArray()); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) - .body(JSON.toJSONString(params)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { - throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); - }); - XxlJobLogger.log("接收到答案:"+JSON.toJSONString(response.body())); - List result = JSONArray.parseArray(response.body(), AnswerVO.class); - if(CollectionUtil.isNotEmpty(result)) { - logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); - } - return result; - } - - - - @Override - public Boolean authentication(String stationId, String userId, String func,String sessionId) { - // 站点鉴权 - if(StringUtil.isNotBlank(stationId)) { - authenticationService.stationAuthentication(stationId,userId); - } - // 菜单鉴权 - if(StringUtil.isNotBlank(func) && StringUtil.isNotBlank(userId)) { - authenticationService.menuAuthentication(userId,func); - } - // 遥控鉴权 - if(FuncRouteEnum.CONFIRM_YK.getFuncCode().equals(func)) { - authenticationService.remoteAuthentication(stationId,userId,sessionId); - } - return true; - } - - @Override - public Boolean removeSessionId(String sessionId) { - // 调用大模型删除对话 - Map params = new HashMap<>(); - params.put("id",sessionId); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAskAbort()) - .body(JSON.toJSONString(params)).execute(); - if(response.getStatus() != HttpServletResponse.SC_OK) { - log.error("远程调用大模型【删除对话】接口失败!"); - throw new ServiceException("远程调用大模型【删除对话】接口失败!"); - } - // 移除对应reids中问题标记 - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,sessionId); - return true; - } - - /** - * 发起知识库问答 - */ - @Override - public R knowledgeAsk(String question, String sessionId, String userId, String knowledge) { - Map params = new HashMap<>(); - params.put("id", sessionId); - params.put("userid", userId); - params.put("query", question); - params.put("knowledge", knowledge); - params.put("stationids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) - .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); - params.put("projectids", authenticationService.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) - .filter(Func::isNotEmpty).map(String::valueOf).toArray()); - HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk()) - .body(JSON.toJSONString(params)).execute(); - logger.info("interactive:knowledgeAsk", "知识库问答传参为:" + JSON.toJSONString(params) + " 结果为:" + response.body()); - if (response.getStatus() != HttpServletResponse.SC_OK) { - log.error("远程调用大模型【发起知识库问答】接口失败!"); - return R.fail("远程调用大模型【发起知识库问答】接口失败!"); - } - this.addQuestionSessionId(sessionId); - return R.success("消息发送成功"); - } - - /** - * 下发遥控指令 - * @param operate - * @return - */ - @Override - public R sendRemoteControl(ControlDTO operate) { - return remoteClient.sendCtrl(operate); - } - - /** - * 站点发电量 - * @param stationId - * @param startTime - * @param endTime - * @return - */ - @Override - public Double generation(String stationId, String startTime, String endTime) { - // 步骤1.查询站点 - R station = stationClient.getStationByCode(stationId); - if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ - return 0.0; - } - // 步骤2.查询填报发电量 - double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); - - // 步骤3.查询设备 - List devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept())); - if(CollectionUtil.isEmpty(devices)){ - return fill; - } - // 步骤4.遍历设备查询发电量 - // 监控线程执行完后返回结果 - CountDownLatch countDownLatch = new CountDownLatch(devices.size()); - List deviceGenerate = new CopyOnWriteArrayList(); - for(RideDeviceVo device : devices){ - pool.submit(()->{ - deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER)); - }); - countDownLatch.countDown(); - } - //所有模板数据获取完成后释放锁 - try { - countDownLatch.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum(); - } - - /*** - * 指标数据列表查询 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 - * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 - * @param deviceCode 设备编号 - * @param ride 配电比 - * @param signages 指标 - * @return - */ - private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { - AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); - List signboardConditions = new ArrayList<>(); - AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); - analyzeDataConditionPO.setFull(1); - po.setDeviceCode(deviceCode); - analyzeDataConditionPO.setSignages(signages); - analyzeDataConditionPO.setKeepFigures(2); - analyzeDataConditionPO.setAccessRules(accessRules); - analyzeDataConditionPO.setSaveTimeType(cycleType); - // 间隔 - analyzeDataConditionPO.setTimeInterval(1); - analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); - signboardConditions.add(analyzeDataConditionPO); - po.setSignboardConditions(signboardConditions); - R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); - if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - return 0.0; - } - List records = result.getData(); - if(CollectionUtil.isEmpty(records)){ - return 0.0; - } - AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); - if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { - return 0.0; - } - List analyseDataTaosVOList = analyzeDataConditionVO.getList(); - if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { - return 0.0; - } - AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); - if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { - return 0.0; - } - return Double.parseDouble(analyseDataTaosVO.getVal()) * ride; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java deleted file mode 100644 index 71bcc88..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpPageServiceImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFuncParamService; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:46 - */ -@Service -@AllArgsConstructor -@Slf4j -@Deprecated -public class JumpPageServiceImpl implements IJumpPageService { - - private final IFuncParamService paramService; - private final JumpRouteJoinStrategy strategy; - - @Override - public String dealJumpTypeFunction(FunctionEntity function,Map args) { - List params = paramService.getParamsByFuncId(function.getId()); - Optional paramOptional = params.stream().filter(p -> p.getIsRequire()).filter(p -> !args.containsKey(p.getAlias())).findAny(); - Assert.isTrue(!paramOptional.isPresent(), () -> { - throw new ServiceException("解析参数失败,缺少参数:" + paramOptional.get().getName()); - }); - // 跳转页面逻辑 - ExtraVO extraVO = strategy.resolve(function,args); - return JSON.toJSONString(extraVO); - } -} 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 e2e1cbd..838d3d7 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 @@ -1,6 +1,5 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; @@ -54,7 +53,7 @@ public class JumpRouteJoinStrategy { // 跳转页面逻辑 ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); Map params = this.scadaResolve(args); // 根据hz3000画面版本获取path Integer picResource = Integer.valueOf(params.get("picResource")); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java index e2a37b2..5a8d80c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java @@ -57,7 +57,7 @@ public class ParamStrategy { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc()); Map params = new HashMap<>(); params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java deleted file mode 100644 index 7d134e1..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamsServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSON; -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.interactive.service.IParamsService; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * @Author: huangxing - * @Date: 2024/05/09 08:51 - */ -@Service -@Slf4j -@AllArgsConstructor -@Deprecated -public class ParamsServiceImpl implements IParamsService { - - private final ParamStrategy strategy; - - @Override - public String dealJumpTypeFunction(FunctionEntity function, Map args) { - // 跳转页面逻辑 - ExtraVO extraVO = strategy.resolve(function,args); - return JSON.toJSONString(extraVO); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java index ee17050..10fbf2e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/VideoResolveServiceImpl.java @@ -7,7 +7,6 @@ import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import groovy.util.logging.Slf4j; @@ -15,7 +14,6 @@ import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -37,9 +35,9 @@ public class VideoResolveServiceImpl implements IResolveService { @Override public ExtraVO resolve(ModelFunctionReq req) { - Map args = req.getFunctionArgs(); - String id = args.get("id"); - String name = args.get("name"); + Map args = req.getItem(); + String id = args.get("itemId"); + String name = args.get("itemName"); Assert.isTrue(StringUtil.isNotBlank(id) && StringUtil.isNotBlank(name),() -> { logger.error("hzims:video:resolve","解析传参错误,缺少必要参数video_id,传参内容为:" + JSON.toJSONString(req)); throw new ServiceException("解析传参错误,缺少必要参数video_id"); @@ -60,7 +58,7 @@ public class VideoResolveServiceImpl implements IResolveService { StationVideoTypeEntity video = videoR.getData(); extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFuncCode()); + extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc()); Map params = new HashMap<>(); params.put("name", video.getName()); params.put("videoHost", video.getVideoHost()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java new file mode 100644 index 0000000..656910e --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java @@ -0,0 +1,67 @@ +package com.hnac.hzims.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; +import com.hnac.hzims.bigmodel.maintenance.service.DataSourceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.*; + +/** + * @Author: huangxing + * @Date: 2024/07/05 16:55 + */ +@RestController +@RequestMapping("/datasource") +@Api(value = "数据源管理",tags = "数据源管理") +public class DataSourceController { + + @Autowired + @Qualifier("dataSourceMaintenanceService") + private DataSourceService dataSourceService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, DatasourceEntity req) { + return R.data(dataSourceService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @GetMapping("/detail") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(dataSourceService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存数据源配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody DatasourceEntity req) { + return R.status(dataSourceService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除数据源配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(dataSourceService.removeByIds(Func.toLongList(",",ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑数据源配置") + @ApiOperationSupport(order = 5) + public R update(@RequestBody DatasourceEntity req) { + return R.status(dataSourceService.updateById(req)); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java index 79376ff..840f784 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TableColumnController.java @@ -33,22 +33,24 @@ public class TableColumnController { @ApiOperation("获取数据库") @ApiOperationSupport(order = 1) @GetMapping("/getDatabase") - public R>> getDatabase() { - return R.data(tableColumnService.getDatabase()); + public R>> getDatabase(@RequestParam @ApiParam(value = "数据源名") String datasource) { + return R.data(tableColumnService.getDatabase(datasource)); } @ApiOperation("获取数据库表列表") @ApiOperationSupport(order = 2) @GetMapping("/getTables") - public R>> getTables(@RequestParam @ApiParam(value = "数据库名") String database) { - return R.data(tableColumnService.getTables(database)); + public R>> getTables(@RequestParam @ApiParam(value = "数据源名") String datasource, + @RequestParam @ApiParam(value = "数据库名") String database) { + return R.data(tableColumnService.getTables(datasource,database)); } @ApiOperation("获取数据库表列列表") @ApiOperationSupport(order = 3) @GetMapping("/getColumns") - public R>> getColumns(@RequestParam @ApiParam(value = "数据库名") String database, + public R>> getColumns(String datasource, + @RequestParam @ApiParam(value = "数据源名") String database, @RequestParam @ApiParam(value = "数据库表名") String tableName) { - return R.data(tableColumnService.getColumns(database,tableName)); + return R.data(tableColumnService.getColumns(datasource,database,tableName)); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java new file mode 100644 index 0000000..88412f0 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; +import com.hnac.hzims.bigmodel.maintenance.service.TablePropertyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:19 + */ +@RestController +@RequestMapping("/table/property") +@Api(value = "表配置",tags = "表配置") +@AllArgsConstructor +public class TablePropertyController { + + private final TablePropertyService tablePropertyService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, TablePropertyEntity req) { + return R.data(tablePropertyService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @GetMapping("/detail") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(tablePropertyService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存表配置") + @ApiOperationSupport(order = 3) + public R save(@RequestBody TablePropertyEntity req) { + return R.status(tablePropertyService.save(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除表配置") + @ApiOperationSupport(order = 4) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(tablePropertyService.removeByIds(Func.toLongList(",",ids))); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑表配置") + @ApiOperationSupport(order = 5) + public R update(@RequestBody TablePropertyEntity req) { + return R.status(tablePropertyService.updateById(req)); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java new file mode 100644 index 0000000..0ed6f68 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/DatasourceEntity.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/05 14:45 + */ +@Data +@EqualsAndHashCode +@TableName("HZIMS_DATASOURCE") +@ApiModel(value = "数据源配置",description = "数据源配置") +public class DatasourceEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("数据源名称") + @QueryField(condition = SqlCondition.LIKE) + private String datasourceName; + + @ApiModelProperty("数据库名称") + @QueryField(condition = SqlCondition.LIKE) + private String databaseName; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java new file mode 100644 index 0000000..003d46b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/TablePropertyEntity.java @@ -0,0 +1,49 @@ +package com.hnac.hzims.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/05 14:49 + */ +@ApiModel("数据库表配置") +@TableName("HZIMS_TABLE_PROPERTY") +@Data +public class TablePropertyEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("数据源Id") + @QueryField(condition = SqlCondition.EQUAL) + @NotNull + private Long datasourceId; + + @ApiModelProperty("数据源名称") + @QueryField(condition = SqlCondition.LIKE) + @NotNull + private String datasourceName; + + @ApiModelProperty("数据库名") + @QueryField(condition = SqlCondition.LIKE) + @NotBlank + private String databaseName; + + @ApiModelProperty("数据表名") + @QueryField(condition = SqlCondition.LIKE) + @NotBlank + private String tableName; + + @ApiModelProperty("鉴权类型") + @QueryField(condition = SqlCondition.EQUAL) + @NotBlank + private String authType; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java new file mode 100644 index 0000000..b62ce18 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/DatasourceMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:05 + */ +public interface DatasourceMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java new file mode 100644 index 0000000..e4d1333 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/TablePropertyMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:12 + */ +public interface TablePropertyMapper extends BaseMapper { +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java new file mode 100644 index 0000000..a58f598 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/DataSourceService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.bigmodel.maintenance.service; + +import com.hnac.hzims.bigmodel.maintenance.entity.DatasourceEntity; +import com.hnac.hzims.bigmodel.maintenance.mapper.DatasourceMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:06 + */ +@Service("dataSourceMaintenanceService") +@Slf4j +@AllArgsConstructor +public class DataSourceService extends BaseServiceImpl { + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java index 8c31998..888d575 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java @@ -20,19 +20,19 @@ public class TableColumnService { private final DataSourceService dataSourceService; - public List> getDatabase() { - String sql = "select distinct `table_schema` from `tables` where `table_schema` <> 'information_schema';"; - return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + public List> getDatabase(String datasource) { + String sql = "select distinct `table_schema` from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } - public List> getTables(String database) { - String sql = "select distinct `table_name` from `tables` where `table_schema` = '" + database + "';"; - return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + public List> getTables(String datasource,String database) { + String sql = "select distinct `table_name` from `information_schema`.`tables` where `table_schema` = '" + database + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } - public List> getColumns(String database,String tableName) { - String sql = "select `COLUMN_NAME` from `COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; - return dataSourceService.queryListOnSpecificDataSource(sql,"information"); + public List> getColumns(String datasource,String database,String tableName) { + String sql = "select distinct `column_name`,`column_comment` from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; + return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java new file mode 100644 index 0000000..f78294b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TablePropertyService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.maintenance.service; + +import com.hnac.hzims.bigmodel.maintenance.entity.TablePropertyEntity; +import com.hnac.hzims.bigmodel.maintenance.mapper.TablePropertyMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/05 15:11 + */ +@Service +@AllArgsConstructor +@Slf4j +public class TablePropertyService extends BaseServiceImpl { + +} 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 deleted file mode 100644 index 6ca3031..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.hnac.hzims.bigmodel.schedule; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; -import com.hnac.hzims.bigmodel.interactive.service.impl.ExtraResolveStrategyService; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; -import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; -import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; -import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; -import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; -import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; -import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasVO; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import com.xxl.job.core.log.XxlJobLogger; -import lombok.AllArgsConstructor; -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.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; - -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.stream.Collectors; - -import static com.hnac.hzims.bigmodel.schedule.XxlJobHandlerConstant.*; - -/** - * @Author: huangxing - * @Date: 2024/04/28 16:18 - */ -@Component -@AllArgsConstructor -@Deprecated -public class InteractiveSchedule { - - private final InteractiveWsService wsService; - - private final IInteractiveService interactiveService; - - private final ThreadPoolExecutor getAnswerPoolExecutor; - - private final RedisTemplate redisTemplate; - - private final IStationVideoTypeClient videoClient; - - private final ProjectClient projectClient; - - private final ScadaClient scadaClient; - - private final IStationClient stationClient; - - private final ExtraResolveStrategyService extraResolveStrategyService; - - // @XxlJob(GET_INTERACTIVE_RESULT) - public ReturnT getInteractiveResult(String params) { - List sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); - if(CollectionUtil.isEmpty(sessionIds)){ - XxlJobLogger.log("问题都已经回答完毕!"); - return ReturnT.SUCCESS; - } - List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); - answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> { - // 如果已经获取到答案 则删除缓存 - if(answerVO.getRunning() == 0) { - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); - } - Object[] extras = answerVO.getExtras(); - if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){ - try { - List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); - answerVO.setExtras(extraList.toArray(new String[extraList.size()])); - } - catch(Exception e) { - e.printStackTrace(); - AnswerVO.error(answerVO); - answerVO.setAnswer("非常抱歉,系统在处理您的请求时遇到了问题。请稍后再试或联系我们的客服团队。"); - } - } - if(sessionIds.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - if(Func.isNotEmpty(session)) { - wsService.sendMessage(session,message); - } - } - }, getAnswerPoolExecutor)); - return ReturnT.SUCCESS; - } - - @XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) - public ReturnT synchronousVideoInstruct(String params) { - Map request = new HashMap<>(2); - // 获取站点列表 - R> stationsR = stationClient.list(new StationEntity()); - if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { - XxlJobLogger.log("获取站点列表失败!"); - return ReturnT.FAIL; - } - List updateStationList = stationsR.getData().stream().map(station -> { - UpdateStationVO stationVO = new UpdateStationVO(); - stationVO.setId(station.getCode()); - stationVO.setName(station.getName()); - return stationVO; - }).collect(Collectors.toList()); - request.put("stations", updateStationList); - // 获取视频列表 - R> videoListR = videoClient.list(new StationVideoTypeEntity()); - if(!videoListR.isSuccess() || CollectionUtil.isEmpty(videoListR.getData())) { - XxlJobLogger.log("获取视频列表失败!"); - return ReturnT.FAIL; - } - List updateUsualList = videoListR.getData().stream().map(video -> { - UpdateUsualVO usualVO = new UpdateUsualVO(); - usualVO.setStationId(video.getStationId()); - usualVO.setId(String.valueOf(video.getId())); - usualVO.setName(video.getName()); - return usualVO; - }).collect(Collectors.toList()); - request.put("videos", updateUsualList); - // 同步指令 - interactiveService.updateVideo(request); - return ReturnT.SUCCESS; - } - - @XxlJob(SYNCHRONOUS_SCADA_INSTRUCT) - public ReturnT synchronousScadaInstruct(String params) { - // 查询项目数据 - Result> projects = projectClient.getProjectByAppId(); - if(!projects.isSuccess() || CollectionUtil.isEmpty(projects.getData())){ - return ReturnT.SUCCESS; - } - // 请求fdp同步实时画面方法参数定义 - Map param = new HashMap<>(2); - List stations = projects.getData().stream().map(station -> { - UpdateStationVO updateStation = new UpdateStationVO(); - updateStation.setId(station.getId()); - updateStation.setName(station.getName()); - return updateStation; - }).collect(Collectors.toList()); - param.put("stations", stations); - // 查询画面信息 - Result> canvas = scadaClient.getCanvasList(projects.getData().stream().map(ProjectVO::getId).collect(Collectors.toList())); - if(!canvas.isSuccess() || CollectionUtil.isEmpty(canvas.getData())) { - return ReturnT.SUCCESS; - } - List updateUsuals = canvas.getData().stream().map(canva -> { - UpdateUsualVO usualVO = new UpdateUsualVO(); - usualVO.setStationId(canva.getProjectId()); - usualVO.setName(canva.getName()); - // 画面id = - String id = Optional.of(canva.getPicSource()).map(String::valueOf).orElse("") + "^" + - Optional.ofNullable(canva.getContext()).orElse("") + "^" + - Optional.ofNullable(canva.getStationNum()).orElse("") + "^" + - Optional.ofNullable(canva.getProjectId()).orElse("") + "^" + - Optional.ofNullable(canva.getTaskId()).map(String::valueOf).orElse("") + "^" + - Optional.ofNullable(canva.getName()).orElse("") + "^" + - Optional.ofNullable(canva.getId()).map(String::valueOf).orElse("") + "^"; - usualVO.setId(id); - return usualVO; - }).collect(Collectors.toList()); - param.put("canvases", updateUsuals); - Boolean status = interactiveService.updateCanvas(param); - return ReturnT.SUCCESS; - } - - @XxlJob(SYNCHRONOUS_FAULT_INSTRUCT) - public ReturnT synchronousFaultInstruct(String params) { - Map request = new HashMap<>(2); - // 获取站点列表 - R> stationsR = stationClient.list(new StationEntity()); - if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { - XxlJobLogger.log("获取站点列表失败!"); - return ReturnT.FAIL; - } - List updateStationList = stationsR.getData().stream().map(station -> { - UpdateStationVO stationVO = new UpdateStationVO(); - stationVO.setId(station.getCode()); - stationVO.setName(station.getName()); - return stationVO; - }).collect(Collectors.toList()); - request.put("stations", updateStationList); - interactiveService.updateFault(request); - return ReturnT.SUCCESS; - } -} 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 594981b..2c76eb5 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 @@ -13,15 +13,11 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; @@ -33,7 +29,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.function.Function; /** * @Author: huangxing @@ -94,13 +89,11 @@ public class InteractiveHandler extends TextWebSocketHandler { String context = messageContext.getString("context"); String userId = messageContext.getString("userId"); String knowledge = messageContext.getString("knowledge"); - IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + IHznlmInvokeService hznlmInvokeService = SpringUtil.getBean(IHznlmInvokeService.class); if (knowledge != null) { - R askResult = interactiveService.knowledgeAsk(context, sessionId, userId, knowledge); - log.info("知识库问答返回结果:" + JSON.toJSONString(askResult)); + hznlmInvokeService.knowledgeAsk(context, sessionId, userId, knowledge); } else { - R askResult = interactiveService.ask(context, sessionId, userId); - log.info("返回结果为:"+ JSON.toJSONString(askResult)); + hznlmInvokeService.ask(context, sessionId, userId); } } else { @@ -170,7 +163,7 @@ public class InteractiveHandler extends TextWebSocketHandler { Map param = new HashMap<>(1); param.put("canvas_id",selection.getId()); IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); - FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFuncCode()); + FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFunc()); ExtraVO scadaExtra = strategy.getScadaExtra(param, function); AnswerVO answerVO = new AnswerVO(); answerVO.setSessionId(sessionId); diff --git a/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql b/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql new file mode 100644 index 0000000..8c3c5cc --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/resources/db/2.0.0.sql @@ -0,0 +1,31 @@ +CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `DATASOURCE_ID` BIGINT(50) NOT NULL COMMENT '数据源Id', + `DATASOURCE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', + `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', + `TABLE_NAME` varchar(100) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据表名', + `AUTH_TYPE` varchar(20) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '鉴权类型', + `TENANT_ID` varchar(12) CHARACTER SET utf8 DEFAULT NULL COMMENT '租户ID', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; + +CREATE TABLE IF NOT EXISTS `HZIMS_TABLE_PROPERTY` ( + `ID` bigint(20) NOT NULL COMMENT '主键ID', + `DATASOURCE_NAME` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '数据源名', + `DATABASE_NAME` varchar(50) NOT NULL COLLATE utf8mb4_bin NOT NULL COMMENT '数据库名', + `STATUS` bigint(1) DEFAULT NULL COMMENT '状态', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='数据库表配置'; \ No newline at end of file From 55d24f867d98bbefc8e6abfe82a5395e5649e421 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 10 Jul 2024 19:17:44 +0800 Subject: [PATCH 149/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java | 20 +++ .../hzims/bigmodel/api/dto/ControlSyncDTO.java | 20 +++ .../com/hnac/hzims/bigmodel/api/dto/SyncDTO.java | 50 +++++++ .../hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java | 20 +++ .../bigmodel/api/feign/ICanvasSyncClient.java | 12 ++ .../bigmodel/api/feign/IControlSyncClient.java | 11 ++ .../hnac/hzims/bigmodel/api/feign/ISyncClient.java | 40 ++++++ .../hzims/bigmodel/api/feign/IVideoSyncClient.java | 33 +++++ .../hzims/bigmodel/business/feign/IAuthClient.java | 10 ++ .../hzims/bigmodel/interactive/vo/DataItemVO.java | 2 +- .../hzims/bigmodel/interactive/vo/SelectionVO.java | 7 +- .../hzims/bigmodel/api/feign/VideoSyncClient.java | 35 +++++ .../hzims/bigmodel/api/service/SyncService.java | 16 +++ .../control/DataSourceExecuteController.java | 33 +++++ .../business/control/RemoteController.java | 36 ++++++ .../hzims/bigmodel/business/feign/AuthClient.java | 36 ++++++ .../business/service/AuthenticationService.java | 27 ++-- .../business/service/DataSourceService.java | 121 +++++++++++++++++ .../business/service/HistoryDataService.java | 97 ++++++++++++++ .../bigmodel/business/service/RemoteService.java | 31 +++++ .../com/hnac/hzims/bigmodel/business/vo/SqlVO.java | 32 +++++ .../hzims/bigmodel/business/vo/TableAuthVO.java | 28 ++++ .../bigmodel/data/controller/RemoteController.java | 37 ------ .../bigmodel/data/service/HistoryDataService.java | 97 -------------- .../hzims/bigmodel/data/service/RemoteService.java | 31 ----- .../controller/DataSourceExecuteController.java | 33 ----- .../datasource/service/DataSourceService.java | 128 ------------------ .../hnac/hzims/bigmodel/datasource/vo/SqlVO.java | 32 ----- .../hzims/bigmodel/datasource/vo/TableAuthVO.java | 28 ---- .../function/controller/FunctionController.java | 73 ----------- .../controller/FunctionParamController.java | 74 ----------- .../bigmodel/function/mapper/FuncParamMapper.java | 11 -- .../bigmodel/function/mapper/FunctionMapper.java | 12 -- .../function/service/IFuncParamService.java | 21 --- .../function/service/IFunctionService.java | 14 -- .../service/impl/FuncParamServiceImpl.java | 28 ---- .../function/service/impl/FunctionServiceImpl.java | 27 ---- .../controller/HznlmInteractiveController.java | 5 +- .../interactive/service/IHznlmInvokeService.java | 10 ++ .../interactive/service/IInteractiveService.java | 58 --------- .../interactive/service/IJumpPageService.java | 17 --- .../service/impl/AnalyseDataServiceImpl.java | 2 +- .../service/impl/CanvasResolveServiceImpl.java | 6 +- .../service/impl/HznlmInvokeServiceImpl.java | 51 +++++--- .../service/impl/JumpRouteJoinStrategy.java | 144 --------------------- .../interactive/service/impl/ParamStrategy.java | 73 ----------- .../hzims/bigmodel/interactive/vo/AnswerVO.java | 4 +- .../bigmodel/interactive/vo/RemoteParamVO.java | 2 +- .../maintenance/service/TableColumnService.java | 3 +- .../hzims/bigmodel/question/dto/MessageDTO.java | 106 +++++++++++++++ .../hzims/bigmodel/question/dto/QuestionDTO.java | 78 +++++++++++ .../question/service/QuestionHandlerService.java | 123 ++++++++++++++++++ .../schedule/FrontEndInteractiveSchedule.java | 2 +- .../hzims/bigmodel/utils/RequestClientUtil.java | 18 ++- .../websocket/handler/InteractiveHandler.java | 68 +++++----- 55 files changed, 1115 insertions(+), 1018 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java new file mode 100644 index 0000000..45a4bd0 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/CanvasSyncDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:48 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "实时画面同步DTO对象",description = "实时画面同步DTO对象") +public class CanvasSyncDTO extends SyncDTO implements Serializable { + + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java new file mode 100644 index 0000000..a1121fd --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/ControlSyncDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:51 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "遥控同步DTO对象",description = "遥控同步DTO对象") +public class ControlSyncDTO extends SyncDTO implements Serializable { + + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java new file mode 100644 index 0000000..19507de --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java @@ -0,0 +1,50 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:33 + */ +@Data +@EqualsAndHashCode +@ApiModel(value = "视频同步DTO",description = "视频同步DTO") +public class SyncDTO implements Serializable { + + @ApiModelProperty("数据ID") + private String id; + + @ApiModelProperty("在问答流程中使用的数据ID") + @JSONField(name = "item_id") + private String itemId; + + @ApiModelProperty("用于匹配的名字。应包含所有匹配相关信息") + @JSONField(name = "item_name") + private String itemName; + + @ApiModelProperty("类型,可为'平台'或'业务'") + private String type; + + @ApiModelProperty("站点I,平台yk必须有,否则可为null") + @JSONField(name = "station_id") + private String stationId; + + @ApiModelProperty("站点名称,平台yk必须有,否则可为null") + @JSONField(name = "station_name") + private String stationName; + + @ApiModelProperty("设备ID,平台yk必须有,否则可为null") + @JSONField(name = "device_id") + private String deviceId; + + @ApiModelProperty("设备名称,平台yk必须有,否则可为null") + @JSONField(name = "device_name") + private String deviceName; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java new file mode 100644 index 0000000..3969228 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:42 + */ +@ApiModel(value = "视频同步DTO对象",description = "视频同步DTO对象") +@Data +@EqualsAndHashCode +public class VideoSyncDTO extends SyncDTO implements Serializable { + + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java new file mode 100644 index 0000000..e92cfec --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ICanvasSyncClient.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.api.dto.CanvasSyncDTO; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:53 + */ +public interface ICanvasSyncClient extends ISyncClient { + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java new file mode 100644 index 0000000..f35a680 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IControlSyncClient.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.api.dto.ControlSyncDTO; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:55 + */ +public interface IControlSyncClient extends ISyncClient { + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java new file mode 100644 index 0000000..8744be5 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.api.dto.SyncDTO; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:32 + */ +public interface ISyncClient { + + String SAVE_BATCH = "/saveBatch"; + String UPDATE_BY_ID = "/updateById"; + String DELETE_BY_IDS = "/deleteByIds"; + + /** + * 同步 - 新增对象 + * @param syncDTO 同步对象列表 + * @return 同步结果 + */ + R saveBatch(List syncDTO); + + /** + * 同步 - 更新对象 + * @param syncDTO 同步对象 + * @return 同步结果 + */ + R updateById(T syncDTO); + + /** + * 同步 - 删除对象 + * @param ids 主键id按逗号分隔 + * @return 删除结果 + */ + R deleteByIds(String ids); + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java new file mode 100644 index 0000000..5af759e --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.api.dto.SyncDTO; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 19:31 + */ +@FeignClient(name = BigModelConstants.APP_NAME) +public interface IVideoSyncClient extends ISyncClient { + + String PREFIX_API = "/feign/sync/video"; + + @Override + @PostMapping(PREFIX_API + SAVE_BATCH) + R saveBatch(@RequestBody List syncDTO); + + @Override + @PutMapping(PREFIX_API + UPDATE_BY_ID) + R updateById(@RequestBody VideoSyncDTO syncDTO); + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_IDS) + R deleteByIds(@RequestParam String ids); + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java index e4764e7..5301c0d 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/feign/IAuthClient.java @@ -3,6 +3,9 @@ package com.hnac.hzims.bigmodel.business.feign; import com.hnac.hzims.bigmodel.business.dto.ControlDeviceAuthDTO; import org.springblade.core.tool.api.R; +import java.util.List; +import java.util.Map; + /** * @Author: huangxing * @Date: 2024/07/09 09:11 @@ -32,4 +35,11 @@ public interface IAuthClient { * @return 鉴权结果 */ R deptAuth(String userId,String deptId); + + /** + * 获取用户权限数据 + * @param userId 用户ID + * @return 权限数据 + */ + R> getAuthData(String userId); } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java index 15bb8c3..d4e8d76 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java @@ -14,7 +14,7 @@ public class DataItemVO implements Serializable { private String name; - @JSONField(name = "id") + @JSONField(name = "itemId") private String attrId; @JSONField(name = "record_name") diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java index 57899c9..e953435 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/SelectionVO.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.vo; +import com.alibaba.fastjson.annotation.JSONField; import lombok.Data; import java.io.Serializable; @@ -12,9 +13,11 @@ import java.io.Serializable; public class SelectionVO implements Serializable { /**选项ID**/ - private String id; + @JSONField(name = "item_id") + private String itemId; /**选项名称**/ - private String name; + @JSONField(name = "item_name") + private String itemName; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java new file mode 100644 index 0000000..58cf420 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/09 20:17 + */ +@RestController +@AllArgsConstructor +public class VideoSyncClient implements IVideoSyncClient{ + + @Override + @PostMapping(PREFIX_API + SAVE_BATCH) + public R saveBatch(@RequestBody List syncDTO) { + return null; + } + + @Override + @PutMapping(PREFIX_API + UPDATE_BY_ID) + public R updateById(@RequestBody VideoSyncDTO syncDTO) { + return null; + } + + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_IDS) + public R deleteByIds(@RequestParam String ids) { + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java new file mode 100644 index 0000000..422989f --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.api.service; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/07/10 09:03 + */ +@Service +@Slf4j +@AllArgsConstructor +public class SyncService { + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java new file mode 100644 index 0000000..4efcf3b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/DataSourceExecuteController.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.bigmodel.business.control; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.business.service.DataSourceService; +import com.hnac.hzims.bigmodel.business.vo.SqlVO; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/06/28 14:07 + */ +@RestController +@RequestMapping("/dataSource/execute") +@AllArgsConstructor +public class DataSourceExecuteController { + + private final DataSourceService dataSourceService; + + @PostMapping("/executeQuery") + @ApiOperation("执行大模型sql") + @ApiOperationSupport(order = 1) + public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { + return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java new file mode 100644 index 0000000..9f2a798 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/control/RemoteController.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.bigmodel.business.control; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.business.service.RemoteService; +import com.hnac.hzinfo.log.annotation.Business; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:42 + */ +@AllArgsConstructor +@RequestMapping("/remote") +@RestController +@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") +@Business(module = BigModelConstants.APP_NAME,value = "数据平台遥控指令管理") +public class RemoteController { + + private final RemoteService remoteService; + + @ApiOperation("下发遥控指令") + @ApiOperationSupport(order = 1) + @PostMapping("/sendRemoteControl") + public R sendRemoteControl(ControlDTO controlDTO) { + return remoteService.sendRemoteControl(controlDTO); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java index 91ec809..08a3d85 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/feign/AuthClient.java @@ -9,8 +9,11 @@ import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.dto.DeptStationDTO; import org.springframework.stereotype.Component; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /** * @Author: huangxing @@ -23,6 +26,11 @@ public class AuthClient implements IAuthClient { private final AuthenticationService authenticationService; + /** + * 设备控制鉴权 + * @param req 遥控信息 + * @return 鉴权结果 + */ @Override public R remoteAuth(ControlDeviceAuthDTO req) { // 若站点不为空 则对站点进行鉴权 @@ -37,15 +45,43 @@ public class AuthClient implements IAuthClient { return R.success("鉴权成功"); } + /** + * 站点鉴权 + * @param userId 用户ID + * @param stationId 站点ID + * @return 鉴权结果 + */ @Override public R stationAuth(String userId, String stationId) { return R.status(authenticationService.stationAuthentication(stationId,userId)); } + /** + * 机构鉴权 + * @param userId 用户ID + * @param deptId 站点ID + * @return 鉴权结果 + */ @Override public R deptAuth(String userId, String deptId) { List deptStationDTOList = authenticationService.getStationPermissionsById(userId); boolean result = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).anyMatch(d -> Long.valueOf(deptId).equals(d)); return R.status(result); } + + /** + * 获取用户权限数据 + * @param userId 用户ID + * @return 权限数据 - 站点、机构 + */ + @Override + public R> getAuthData(String userId) { + Map result = new HashMap<>(2); + List deptStationDTOList = authenticationService.getStationPermissionsById(userId); + String[] stationIds = deptStationDTOList.stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).toArray(String[]::new); + String[] deptIds = deptStationDTOList.stream().map(DeptStationDTO::getDeptId).map(String::valueOf).toArray(String[]::new); + result.put("stationids",stationIds); + result.put("projectids",deptIds); + return R.data(result); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java index f8e23a0..13db6f2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/AuthenticationService.java @@ -1,8 +1,6 @@ package com.hnac.hzims.bigmodel.business.service; import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.ProjectRemoteTypeEnum; import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; @@ -26,7 +24,6 @@ import org.springframework.util.Assert; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * @Author: huangxing @@ -37,8 +34,6 @@ import java.util.stream.Collectors; public class AuthenticationService { private final IDeptClient deptClient; - private final IFunctionService functionService; - private final IUserClient userClient; private final ProjectClient projectClient; private final IRemoteClient remoteClient; private final RedisTemplate redisTemplate; @@ -50,7 +45,7 @@ public class AuthenticationService { */ public Boolean stationAuthentication(String stationId, String userId) { List deptStationDTOList = this.getStationPermissionsById(userId); - return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(s -> stationId.equals(s)); + return deptStationDTOList.stream().map(DeptStationDTO::getStationId).anyMatch(stationId::equals); } /** @@ -58,15 +53,15 @@ public class AuthenticationService { * @param userId 用户ID * @param func 函数编号 */ - public void menuAuthentication(String userId, String func) { - FunctionEntity function = functionService.getFunctionByCode(func); - if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { - R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); - Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { - throw new ServiceException("人员菜单鉴权失败!"); - }); - } - } +// public void menuAuthentication(String userId, String func) { +// FunctionEntity function = functionService.getFunctionByCode(func); +// if(Func.isNotEmpty(function) && Func.isNotEmpty(function.getRoute()) && StringUtil.isNotBlank(function.getRoute())) { +// R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); +// Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { +// throw new ServiceException("人员菜单鉴权失败!"); +// }); +// } +// } /** * 遥控鉴权 @@ -97,7 +92,7 @@ public class AuthenticationService { }); CtrlAuth ctrlAuth = authOptional.get(); // 如限制机器发送遥控指令 - if(ctrlAuth.getIsLimitMachine().intValue() == 1) { + if(ctrlAuth.getIsLimitMachine() == 1) { SessionContentVO sessionContent = (SessionContentVO) redisTemplate.opsForHash().get(RedisKeyConstants.SESSION_CONTENT_KEY, sessionId); Assert.isTrue(Func.isNotEmpty(sessionContent),() -> { throw new ServiceException("获取问题机器码失败,校验不通过!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java new file mode 100644 index 0000000..5e305aa --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/DataSourceService.java @@ -0,0 +1,121 @@ +package com.hnac.hzims.bigmodel.business.service; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.hnac.hzims.bigmodel.business.vo.SqlVO; +import com.hnac.hzims.bigmodel.business.vo.TableAuthVO; +import com.hnac.hzims.common.service.UserAuthDataService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +/** + * @Author: huangxing + * @Date: 2024/06/28 15:24 + */ +@Service +@AllArgsConstructor +@Slf4j +public class DataSourceService { + + private final JdbcTemplate jdbcTemplate; + private final UserAuthDataService userAuthDataService; + + private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); + private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); + + + public List> queryListOnSpecificDataSource(SqlVO sqlVO) { + // 过滤更新、删除语句 + Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { + throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); + }); + String sql = sqlVO.getSql(); + String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); + for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { + String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; + sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); + } + log.info("执行sql:{}",sql); + return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); + // 过滤更新、删除语句 +// Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { +// throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); +// }); +// String sql = sqlVO.getSql(); +// String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); +// List> tempViewList = Lists.newArrayList(); +// try { +// for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { +// // 创建视图语句 +// String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", ""); +// String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL; +// this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName()); +// Map viewMap = new HashMap(2); +// viewMap.put("datasource",tableAuthVO.getDatasourceName()); +// viewMap.put("viewName",viewName); +// tempViewList.add(viewMap); +// sql = sql.replace(tableAuthVO.getTableName(),viewName); +// } +// log.info("执行sql:{}",sql); +// return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); +// } +// catch(Exception e) { +// log.error("An Error occurred!",e); +// throw new ServiceException("sql执行失败!"); +// } +// finally { +// if(CollectionUtil.isNotEmpty(tempViewList)) { +// tempViewList.forEach(viewMap -> { +// this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource")); +// }); +// } +// } + } + + /** + * sql + * @param sql + * @param dataSourceName + * @return + */ + public List> queryListOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.queryForList(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + + public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { + // 切换到指定的数据源 + DynamicDataSourceContextHolder.push(dataSourceName); + try { + return jdbcTemplate.update(sql); + } finally { + // 清除,恢复默认数据源 + DynamicDataSourceContextHolder.clear(); + } + } + + /** + * 过滤更新、删除语法的sql脚本 + * @param sql 待执行sql脚本 + * @return 执行结果 + */ + public static boolean isUpdateOrDelete(String sql) { + if (sql == null) { + return false; + } + return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java new file mode 100644 index 0000000..edd905c --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/HistoryDataService.java @@ -0,0 +1,97 @@ +package com.hnac.hzims.bigmodel.business.service; + +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; +import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; +import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:57 + */ +@Service +@Slf4j +@AllArgsConstructor +public class HistoryDataService { + + private final DeviceDataClient deviceDataClient; + private final BladeLogger logger; + public static final int DATA_COUNT_MAX = 1000; + + public Result getPolymerizationData(HistoryDataSearchVO searchVO) { + DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); + Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { + throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); + }); + // 聚合数据方式处理 + DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); + ReductionDataDTO dataDTO = new ReductionDataDTO(); + ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); + reductionAttrData.setSignage(searchVO.getSignage()); + reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); + reductionAttrData.setKeepFigures(2); + dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); + dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); + dataDTO.setDeviceCode(searchVO.getDeviceCode()); + dataDTO.setNeedPage(false); + dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); + dataDTO.setTimeInterval(1); + dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); + logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); + return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); + } + + public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { + LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); + LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); + Duration duration = Duration.between(start, end); + int count; + switch(dateEnum) { + case YEAR: + count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case MONTH: + count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case DAY: + count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); + break; + case HOUR: + count = Long.valueOf(duration.toHours()).intValue(); + break; + case MINUTE: + count = Long.valueOf(duration.toMinutes()).intValue(); + break; + case SECOND: + count = Long.valueOf(duration.getSeconds()).intValue(); + break; + default: + throw new ServiceException("未找到相关时间类型,查询失败!"); + } + if(count <= DATA_COUNT_MAX) { + return dateEnum; + } + else { + return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); + } + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java new file mode 100644 index 0000000..96e8259 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/service/RemoteService.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.bigmodel.business.service; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.system.dto.ControlDTO; +import org.springblade.system.feign.IRemoteClient; +import org.springframework.stereotype.Service; + +/** + * @Author: huangxing + * @Date: 2024/06/24 14:36 + * @Descirbe: 数据平台 - 遥控服务类 + */ +@Service +@Slf4j +@AllArgsConstructor +public class RemoteService { + + private final IRemoteClient remoteClient; + + /** + * 发送遥控指令 + * @param controlDTO 遥控指令 + * @return 结果 + */ + public R sendRemoteControl(ControlDTO controlDTO) { + return remoteClient.sendCtrl(controlDTO); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java new file mode 100644 index 0000000..5a5bff8 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/SqlVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.bigmodel.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/07/05 08:19 + */ +@ApiModel(value = "",description = "") +@Data +@EqualsAndHashCode +public class SqlVO implements Serializable { + + @ApiModelProperty("执行sql") + @NotBlank + private String sql; + + @ApiModelProperty("执行人") + @NotBlank + private String userId; + + @ApiModelProperty("执行sql设计表信息") + private List tableAuthVOList; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java new file mode 100644 index 0000000..b1524fa --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/vo/TableAuthVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.business.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/07/04 17:29 + */ +@ApiModel(value = "表鉴权对象",description = "表鉴权对象") +@Data +@EqualsAndHashCode +public class TableAuthVO implements Serializable { + + @ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") + private String auth; + + @ApiModelProperty("数据源名称") + private String datasourceName; + + @ApiModelProperty("数据表名称") + private String tableName; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java deleted file mode 100644 index c420ba7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/controller/RemoteController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hnac.hzims.bigmodel.data.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.data.service.RemoteService; -import com.hnac.hzinfo.log.annotation.Business; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:42 - */ -@AllArgsConstructor -@RequestMapping("/remote") -@RestController -@Api(value = "数据平台遥控指令管理",tags = "数据平台遥控指令管理") -@Business(module = BigModelConstants.APP_NAME,value = "数据平台遥控指令管理") -public class RemoteController { - - private final RemoteService remoteService; - - @ApiOperation("下发遥控指令") - @ApiOperationSupport(order = 1) - @PostMapping("/sendRemoteControl") - public R sendRemoteControl(ControlDTO controlDTO) { - return remoteService.sendRemoteControl(controlDTO); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java deleted file mode 100644 index a9f854c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/HistoryDataService.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.hnac.hzims.bigmodel.data.service; - -import com.alibaba.fastjson.JSON; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; -import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; -import com.hnac.hzims.bigmodel.interactive.vo.HistoryDataSearchVO; -import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionAttrDataDTO; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; -import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.log.logger.BladeLogger; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:57 - */ -@Service -@Slf4j -@AllArgsConstructor -public class HistoryDataService { - - private final DeviceDataClient deviceDataClient; - private final BladeLogger logger; - public static final int DATA_COUNT_MAX = 1000; - - public Result getPolymerizationData(HistoryDataSearchVO searchVO) { - DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); - Assert.isTrue(Func.isNotEmpty(enumByMethod),() -> { - throw new ServiceException("数据查询聚合方式传参有误,查询失败!"); - }); - // 聚合数据方式处理 - DateEnum dateEnum = DateEnum.getDateEnumByType(searchVO.getDataType()); - ReductionDataDTO dataDTO = new ReductionDataDTO(); - ReductionAttrDataDTO reductionAttrData = new ReductionAttrDataDTO(); - reductionAttrData.setSignage(searchVO.getSignage()); - reductionAttrData.setAccessRules(enumByMethod.getAccessRule()); - reductionAttrData.setKeepFigures(2); - dataDTO.setBeginTime(LocalDateTime.parse(searchVO.getStartTime(), DateUtil.DATETIME_FORMATTER)); - dataDTO.setEndTime(LocalDateTime.parse(searchVO.getEndTime(),DateUtil.DATETIME_FORMATTER)); - dataDTO.setDeviceCode(searchVO.getDeviceCode()); - dataDTO.setNeedPage(false); - dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); - dataDTO.setTimeInterval(1); - dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); - logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); - return deviceDataClient.pageDeviceCodeAndSignages(dataDTO); - } - - public DateEnum getDateEnumByDuration(String startTime,String endTime,DateEnum dateEnum) { - LocalDateTime start = LocalDateTime.parse(startTime, DateUtil.DATETIME_FORMATTER); - LocalDateTime end = LocalDateTime.parse(endTime, DateUtil.DATETIME_FORMATTER); - Duration duration = Duration.between(start, end); - int count; - switch(dateEnum) { - case YEAR: - count = Long.valueOf(ChronoUnit.YEARS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case MONTH: - count = Long.valueOf(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case DAY: - count = Long.valueOf(ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate())).intValue(); - break; - case HOUR: - count = Long.valueOf(duration.toHours()).intValue(); - break; - case MINUTE: - count = Long.valueOf(duration.toMinutes()).intValue(); - break; - case SECOND: - count = Long.valueOf(duration.getSeconds()).intValue(); - break; - default: - throw new ServiceException("未找到相关时间类型,查询失败!"); - } - if(count <= DATA_COUNT_MAX) { - return dateEnum; - } - else { - return getDateEnumByDuration(startTime, endTime, DateEnum.getDateEnumByOrder(dateEnum.getOrder() + 1)); - } - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java deleted file mode 100644 index 551a10b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/data/service/RemoteService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.bigmodel.data.service; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; -import org.springblade.system.feign.IRemoteClient; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/06/24 14:36 - * @Descirbe: 数据平台 - 遥控服务类 - */ -@Service -@Slf4j -@AllArgsConstructor -public class RemoteService { - - private final IRemoteClient remoteClient; - - /** - * 发送遥控指令 - * @param controlDTO 遥控指令 - * @return 结果 - */ - public R sendRemoteControl(ControlDTO controlDTO) { - return remoteClient.sendCtrl(controlDTO); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java deleted file mode 100644 index 0542fea..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/controller/DataSourceExecuteController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.bigmodel.datasource.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; -import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/06/28 14:07 - */ -@RestController -@RequestMapping("/dataSource/execute") -@AllArgsConstructor -public class DataSourceExecuteController { - - private final DataSourceService dataSourceService; - - @PostMapping("/executeQuery") - @ApiOperation("执行大模型sql") - @ApiOperationSupport(order = 1) - public R>> executeQuery(@RequestBody @Valid SqlVO sqlVO) { - return R.data(dataSourceService.queryListOnSpecificDataSource(sqlVO)); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java deleted file mode 100644 index 5cb211f..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/service/DataSourceService.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.hnac.hzims.bigmodel.datasource.service; - -import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; -import com.hnac.hzims.bigmodel.datasource.vo.TableAuthVO; -import com.hnac.hzims.common.service.UserAuthDataService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * @Author: huangxing - * @Date: 2024/06/28 15:24 - */ -@Service -@AllArgsConstructor -@Slf4j -public class DataSourceService { - - private final JdbcTemplate jdbcTemplate; - private final UserAuthDataService userAuthDataService; - - private static final Pattern UPDATE_PATTERN = Pattern.compile("^UPDATE\\s", Pattern.CASE_INSENSITIVE); - private static final Pattern DELETE_PATTERN = Pattern.compile("^DELETE\\s", Pattern.CASE_INSENSITIVE); - - - public List> queryListOnSpecificDataSource(SqlVO sqlVO) { - // 过滤更新、删除语句 - Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { - throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); - }); - String sql = sqlVO.getSql(); - String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); - for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { - String tableSubStr = "(SELECT * FROM " + tableAuthVO.getTableName() + " where" + userAuthDataSQL +") temp"; - sql = sql.replace(tableAuthVO.getTableName(),tableSubStr); - } - log.info("执行sql:{}",sql); - return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); - // 过滤更新、删除语句 -// Assert.isTrue(!DataSourceService.isUpdateOrDelete(sqlVO.getSql()),() -> { -// throw new ServiceException("执行sql语句包含更新/删除操作,执行失败!"); -// }); -// String sql = sqlVO.getSql(); -// String userAuthDataSQL = userAuthDataService.getUserAuthDataSQL(Long.parseLong(sqlVO.getUserId())); -// List> tempViewList = Lists.newArrayList(); -// try { -// for (TableAuthVO tableAuthVO : sqlVO.getTableAuthVOList()) { -// // 创建视图语句 -// String viewName = "V_TEMP_" + UUID.randomUUID().toString().replace("-", ""); -// String createView = "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableAuthVO.getTableName() + " where " + userAuthDataSQL; -// this.updateOnSpecificDataSource(createView,tableAuthVO.getDatasourceName()); -// Map viewMap = new HashMap(2); -// viewMap.put("datasource",tableAuthVO.getDatasourceName()); -// viewMap.put("viewName",viewName); -// tempViewList.add(viewMap); -// sql = sql.replace(tableAuthVO.getTableName(),viewName); -// } -// log.info("执行sql:{}",sql); -// return this.queryListOnSpecificDataSource(sql, sqlVO.getTableAuthVOList().get(0).getDatasourceName()); -// } -// catch(Exception e) { -// log.error("An Error occurred!",e); -// throw new ServiceException("sql执行失败!"); -// } -// finally { -// if(CollectionUtil.isNotEmpty(tempViewList)) { -// tempViewList.forEach(viewMap -> { -// this.updateOnSpecificDataSource("DROP VIEW IF EXISTS `" + viewMap.get("viewName")+"`;",viewMap.get("datasource")); -// }); -// } -// } - } - - /** - * sql - * @param sql - * @param dataSourceName - * @return - */ - public List> queryListOnSpecificDataSource(String sql,String dataSourceName) { - // 切换到指定的数据源 - DynamicDataSourceContextHolder.push(dataSourceName); - try { - return jdbcTemplate.queryForList(sql); - } finally { - // 清除,恢复默认数据源 - DynamicDataSourceContextHolder.clear(); - } - } - - public Integer updateOnSpecificDataSource(String sql,String dataSourceName) { - // 切换到指定的数据源 - DynamicDataSourceContextHolder.push(dataSourceName); - try { - return jdbcTemplate.update(sql); - } finally { - // 清除,恢复默认数据源 - DynamicDataSourceContextHolder.clear(); - } - } - - /** - * 过滤更新、删除语法的sql脚本 - * @param sql 待执行sql脚本 - * @return 执行结果 - */ - public static boolean isUpdateOrDelete(String sql) { - if (sql == null) { - return false; - } - return UPDATE_PATTERN.matcher(sql).find() || DELETE_PATTERN.matcher(sql).find(); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java deleted file mode 100644 index 0765c69..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/SqlVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.datasource.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/07/05 08:19 - */ -@ApiModel(value = "",description = "") -@Data -@EqualsAndHashCode -public class SqlVO implements Serializable { - - @ApiModelProperty("执行sql") - @NotBlank - private String sql; - - @ApiModelProperty("执行人") - @NotBlank - private String userId; - - @ApiModelProperty("执行sql设计表信息") - private List tableAuthVOList; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java deleted file mode 100644 index 711fd43..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/datasource/vo/TableAuthVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.datasource.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/07/04 17:29 - */ -@ApiModel(value = "表鉴权对象",description = "表鉴权对象") -@Data -@EqualsAndHashCode -public class TableAuthVO implements Serializable { - - @ApiModelProperty("鉴权类型,目前不为空即为平台数据权限") - private String auth; - - @ApiModelProperty("数据源名称") - private String datasourceName; - - @ApiModelProperty("数据表名称") - private String tableName; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java deleted file mode 100644 index 1d63c64..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionController.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.hnac.hzims.bigmodel.function.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; -import com.hnac.hzims.common.utils.Condition; -import com.hnac.hzinfo.log.annotation.Business; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/04/29 14:39 - */ -@RestController -@RequestMapping("/function") -@Api(value = "大模型函数管理",tags = "大模型函数管理") -@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数管理") -@AllArgsConstructor -public class FunctionController { - - private final IFunctionService functionService; - - @PostMapping("/save") - @ApiOperation("保存函数") - @ApiOperationSupport(order = 1) - public R save(@RequestBody @Validated FunctionEntity req) { - return R.status(functionService.save(req)); - } - - @PutMapping("/updateById") - @ApiOperation("编辑函数") - @ApiOperationSupport(order = 2) - public R updateById(@RequestBody FunctionEntity req) { - return R.status(functionService.save(req)); - } - - @GetMapping("/list") - @ApiOperation("列表查询") - @ApiOperationSupport(order = 3) - public R> list(FunctionEntity req) { - return R.data(functionService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FunctionEntity.class))); - } - - @GetMapping("/page") - @ApiOperation("分页查询") - @ApiOperationSupport(order = 4) - public R> page(FunctionEntity req, Query query) { - QueryWrapper queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FunctionEntity.class); - return R.data(functionService.page(Condition.getPage(query),queryWrapper)); - } - - @DeleteMapping("/remove") - @ApiOperation("删除函数") - @ApiOperationSupport(order = 4) - public R remove(String ids) { - return R.data(functionService.removeByIds(Func.toLongList(",",ids))); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java deleted file mode 100644 index 0f58067..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/controller/FunctionParamController.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.hnac.hzims.bigmodel.function.controller; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFuncParamService; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; -import com.hnac.hzims.common.utils.Condition; -import com.hnac.hzinfo.log.annotation.Business; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/04/29 15:46 - */ -@RestController -@RequestMapping("/function/param") -@Api(value = "大模型函数参数管理",tags = "大模型函数参数管理") -@Business(module = BigModelConstants.MODULE_NAME,value = "大模型函数参数管理") -@AllArgsConstructor -public class FunctionParamController { - - private final IFuncParamService funcParamService; - - @PostMapping("/save") - @ApiOperation("保存函数参数") - @ApiOperationSupport(order = 1) - public R save(@RequestBody @Validated FuncParamEntity req) { - return R.status(funcParamService.save(req)); - } - - @PutMapping("/save") - @ApiOperation("编辑函数参数") - @ApiOperationSupport(order = 2) - public R updateById(@RequestBody FuncParamEntity req) { - return R.status(funcParamService.save(req)); - } - - @GetMapping("/list") - @ApiOperation("列表查询") - @ApiOperationSupport(order = 3) - public R> list(FuncParamEntity req) { - return R.data(funcParamService.list(Condition.getQueryWrapper(BeanUtil.toMap(req),FuncParamEntity.class))); - } - - @GetMapping("/page") - @ApiOperation("分页查询") - @ApiOperationSupport(order = 4) - public R> page(FuncParamEntity req, Query query) { - QueryWrapper queryWrapper = Condition.getQueryWrapper(BeanUtil.toMap(req), FuncParamEntity.class); - return R.data(funcParamService.page(Condition.getPage(query),queryWrapper)); - } - - @DeleteMapping("/remove") - @ApiOperation("删除函数参数") - @ApiOperationSupport(order = 4) - public R remove(String ids) { - return R.data(funcParamService.removeByIds(Func.toLongList(",",ids))); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java deleted file mode 100644 index 7a9723e..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FuncParamMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.bigmodel.function.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:11 - */ -public interface FuncParamMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java deleted file mode 100644 index 6d0e1c2..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/mapper/FunctionMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.bigmodel.function.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:10 - */ -public interface FunctionMapper extends BaseMapper { - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java deleted file mode 100644 index 39fae6a..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFuncParamService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.bigmodel.function.service; - -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:12 - */ -public interface IFuncParamService extends BaseService { - - /** - * 根据函数ID获取参数列表 - * @param funcId 函数ID - * @return 参数列表 - */ - List getParamsByFuncId(Long funcId); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java deleted file mode 100644 index 6a9e59d..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/IFunctionService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.bigmodel.function.service; - -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:08 - */ -public interface IFunctionService extends BaseService { - - FunctionEntity getFunctionByCode(String code); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java deleted file mode 100644 index e7e2dae..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FuncParamServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.bigmodel.function.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzims.bigmodel.entity.FuncParamEntity; -import com.hnac.hzims.bigmodel.function.mapper.FuncParamMapper; -import com.hnac.hzims.bigmodel.function.service.IFuncParamService; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:13 - */ -@Service -@Slf4j -public class FuncParamServiceImpl extends BaseServiceImpl implements IFuncParamService { - - @Override - public List getParamsByFuncId(Long funcId) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().eq(FuncParamEntity::getFuncId, funcId); - return this.list(queryWrapper); - } - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java deleted file mode 100644 index 0619ddb..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/function/service/impl/FunctionServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hnac.hzims.bigmodel.function.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.mapper.FunctionMapper; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:09 - */ -@Service -@Slf4j -@AllArgsConstructor -public class FunctionServiceImpl extends BaseServiceImpl implements IFunctionService { - - @Override - public FunctionEntity getFunctionByCode(String code) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().eq(FunctionEntity::getCode, code); - return this.getOne(queryWrapper); - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java index 2e8843e..eafdc47 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/HznlmInteractiveController.java @@ -2,15 +2,14 @@ package com.hnac.hzims.bigmodel.interactive.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; -import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; -import com.hnac.hzims.bigmodel.datasource.vo.SqlVO; +import com.hnac.hzims.bigmodel.business.service.DataSourceService; +import com.hnac.hzims.bigmodel.business.vo.SqlVO; import com.hnac.hzims.bigmodel.interactive.dto.AuthDataDTO; import com.hnac.hzims.bigmodel.interactive.dto.ControlDTO; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInteractiveService; import com.hnac.hzims.bigmodel.interactive.vo.AuthDataVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.bigmodel.interactive.vo.ResolveResultVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java index 59c2089..69f319c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IHznlmInvokeService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; import org.springblade.core.tool.api.R; import java.util.List; @@ -19,8 +20,11 @@ public interface IHznlmInvokeService { * @param userId 提问人ID * @return 提问结果 */ + @Deprecated void ask(String question, String sessionId, String userId); + void ask(QuestionDTO question); + /** * 特殊问题 * @param sessionId 会话ID @@ -28,8 +32,11 @@ public interface IHznlmInvokeService { * @param extra 特殊问题内容 * @return 提问结果 */ + @Deprecated void specialAsk(String sessionId, String userId, Map extra); + void specialAsk(QuestionDTO questionDTO); + /** * 知识库问题 * @param question 问题名称 @@ -37,8 +44,11 @@ public interface IHznlmInvokeService { * @param userId 提问人ID * @param knowledge 知识库名称 */ + @Deprecated void knowledgeAsk(String question, String sessionId, String userId, String knowledge); + void knowledgeAsk(QuestionDTO questionDTO); + /** * 删除对话记录 * @param sessionId 会话ID 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 deleted file mode 100644 index e35541b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; -import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import org.springblade.core.tool.api.R; -import org.springblade.system.dto.ControlDTO; - -import java.util.List; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/04/26 14:51 - */ -@Deprecated -public interface IInteractiveService { - - ExtraVO resolveStations(String startTime, String endTime, String type, String enumType); - - R resolve(ModelFunctionReq req); - - R ask(String question,String sessionId,String userId); - - R specialAsk(String sessionId,String userId,Map extra); - - void updateVideo(Map request); - - Boolean updateCanvas(Map request); - - void updateFault(Map request); - - List getAnswerBySessionIds(String sessionIds); - - Boolean authentication(String stationId, String userId, String func,String sessionId); - - Boolean removeSessionId(String sessionId); - - /** - * 发起知识库问答 - * @param question 问题 - * @param sessionId 会话id - * @param userId 用户id - * @param knowledge 知识库名称 - * @return 发起结果 - */ - R knowledgeAsk(String question, String sessionId, String userId, String knowledge); - - R sendRemoteControl(ControlDTO operate); - - Double generation(String stationId, String startTime, String endTime); - - /** - * 获取热点问题 - * @return 热点问题 - */ - List hotQuestions(); -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java deleted file mode 100644 index 5a24baa..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IJumpPageService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service; - -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; - -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/04/26 11:46 - */ -@Deprecated -public interface IJumpPageService { - - String dealJumpTypeFunction(FunctionEntity function, Map args); - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index ae74c7f..9b59e99 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -1,7 +1,7 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.google.common.collect.Lists; -import com.hnac.hzims.bigmodel.data.service.HistoryDataService; +import com.hnac.hzims.bigmodel.business.service.HistoryDataService; import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; import com.hnac.hzims.bigmodel.interactive.constants.DateEnum; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java index b54712b..c4b8f74 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -52,13 +52,13 @@ public class CanvasResolveServiceImpl implements IResolveService { ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); - final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; + final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","itemId"}; String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); // 将ID解析为 Map resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); R stationR = stationClient.getStationByCode(resolveMap.get("projectId")); extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + resolveMap.get("name")); - Integer picResource = Integer.valueOf(resolveMap.get("picResource")); + int picResource = Integer.parseInt(resolveMap.get("picResource")); Map extraParams = new HashMap<>(1); extraParams.put("picResource",picResource); extraVO.setParams(extraParams); @@ -79,7 +79,7 @@ public class CanvasResolveServiceImpl implements IResolveService { context = this.removeHeadChars(context,"/"); context = this.removeTailChars(context,".js"); resolveMap.put("context",context); - extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&name={name}", resolveMap)); + extraVO.setRoute(this.replacePath("other/v4/canvas/index.html?hzinfowebkit=true&taskId={taskId}&stationNum={stationNum}&projectId={projectId}&source=app&picName={context}&itemName={itemName}", resolveMap)); } else { throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index a910692..8d1cee2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -3,16 +3,20 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.business.feign.IAuthClient; import com.hnac.hzims.bigmodel.business.service.AuthenticationService; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.manager.SessionRedisManager; +import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; import com.hnac.hzims.bigmodel.utils.RequestClientUtil; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.dto.DeptStationDTO; @@ -33,10 +37,10 @@ import java.util.Map; @Slf4j public class HznlmInvokeServiceImpl implements IHznlmInvokeService { - private final AuthenticationService authenticationService; private final BigModelInvokeUrl bigModelInvokeUrl; private final BladeLogger logger; private final SessionRedisManager sessionRedisManager; + private final IAuthClient authClient; @Value("${fdp.host}") private String fdpHost; @@ -44,8 +48,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void ask(String question, String sessionId, String userId) { Map params = new HashMap<>(); - params.put("id",sessionId); - params.put("userid", userId); + params.put("chat_id",sessionId); + params.put("user_id", userId); params.put("query",question); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); @@ -54,10 +58,16 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { } @Override + public void ask(QuestionDTO question) { + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override public void specialAsk(String sessionId, String userId, Map extra) { Map params = new HashMap<>(); - params.put("id",sessionId); - params.put("userid", userId); + params.put("chat_id",sessionId); + params.put("user_id", userId); params.put("extra",extra); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); @@ -67,10 +77,16 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { } @Override + public void specialAsk(QuestionDTO question) { + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantSpecialAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { Map params = new HashMap<>(); - params.put("id", sessionId); - params.put("userid", userId); + params.put("chat_id", sessionId); + params.put("user_id", userId); params.put("query", question); params.put("knowledge", knowledge); Map authDataIds = this.getAuthDataIds(userId); @@ -80,6 +96,12 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { } @Override + public void knowledgeAsk(QuestionDTO question) { + RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); + sessionRedisManager.addSessionId(question.getChatId()); + } + + @Override public void removeSessionId(String sessionId) { this.askAbort(sessionId); // 移除内存sessionId @@ -87,6 +109,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { sessionRedisManager.removeSessionId(sessionId); } + @Override public void askAbort(String sessionId) { Map params = new HashMap<>(); params.put("id",sessionId); @@ -107,20 +130,14 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public List getAnswerBySessionIds(String sessionIds) { Map params = new HashMap<>(); - params.put("ids",Func.toStrList(",",sessionIds).toArray()); - List answerVOList = RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference>(){}); - return answerVOList; + params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); + return RequestClientUtil.postCall(fdpHost + bigModelInvokeUrl.getAssistantStatus(), params, new TypeReference>(){}); } private Map getAuthDataIds(String userId) { - List authDatas = authenticationService.getStationPermissionsById(userId); Map result = new HashMap<>(2); - String[] stationIds = authDatas.stream().map(DeptStationDTO::getStationId) - .filter(StringUtil::isNotBlank).toArray(String[]::new); - String[] projectIds = authDatas.stream().map(DeptStationDTO::getDeptId) - .filter(Func::isNotEmpty).map(String::valueOf).toArray(String[]::new); - result.put("stationids", stationIds); - result.put("projectids", projectIds); + R> authDataR = authClient.getAuthData(userId); + result.putAll(authDataR.getData()); return result; } } 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 deleted file mode 100644 index 838d3d7..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.feign.IStationClient; -import lombok.RequiredArgsConstructor; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; - -import java.util.*; -import java.util.stream.IntStream; - -/** - * @Author: huangxing - * @Date: 2024/04/30 11:38 - */ -@Component -@RequiredArgsConstructor -@Deprecated -public class JumpRouteJoinStrategy { - - private final IStationClient stationClient; - - public static String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; - - /** - * 解析大模型传参 - * @param args 大模型传参 - * @return 跳转path所需要的参数 - */ - public ExtraVO resolve(FunctionEntity function,Map args) { - FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); - if(Func.isNotEmpty(routeEnum)) { - switch(routeEnum) { - case OPEN_CANVAS: - return this.getScadaExtra(args,function); - default: - break; - } - } - return null; - } - - public ExtraVO getScadaExtra(Map args,FunctionEntity function) { - // 跳转页面逻辑 - ExtraVO extraVO = new ExtraVO(); - extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); - Map params = this.scadaResolve(args); - // 根据hz3000画面版本获取path - Integer picResource = Integer.valueOf(params.get("picResource")); - JSONObject pathObject = JSONObject.parseObject(function.getPath()); - R stationR = stationClient.getStationByCode(params.get("projectId")); - extraVO.setLabel(Optional.ofNullable(stationR).filter(r -> r.isSuccess()).map(R::getData).map(StationEntity::getName).orElse("") + "_" + params.get("name")); - Map extraParams = new HashMap<>(1); - extraParams.put("picResource",picResource); - extraVO.setParams(extraParams); - // 云组态 - if(picResource == 0) { - String scada = pathObject.getString("scada"); - extraVO.setRoute(this.replacePath(scada, params)); - extraVO.setRoute(scada); - } - // v3.0 - else if (picResource == 1) { - String v3 = pathObject.getString("v3"); - extraVO.setRoute(this.replacePath(v3, params)); - } - // v4.0 - else if (picResource == 2) { - String v4 = pathObject.getString("v4"); - // pic_name 去掉头部的/ 以及尾部的.js - String context = params.get("context"); - context = this.removeHeadChars(context,"/"); - context = this.removeTailChars(context,".js"); - params.put("context",context); - extraVO.setRoute(this.replacePath(v4, params)); - } - else { - throw new ServiceException("解析出来的画面类型在云组态、v3、v4类型之外,无法解析路由"); - } - extraVO.setType(FunctionConstants.TypeEnum.JUMP.getType()); - return extraVO; - } - - /** - * 解析实时画面参数 - * @param args 大模型解析参数 - * @return 实时画面路径拼接所需参数 - */ - public Map scadaResolve(Map args) { - String params = args.get("canvas_id"); - // 参数格式为:picResource^context^stationNum^projectId^taskId^name^id - return this.resolve(params,SCADA_PARAMS_SOLVE); - } - - public 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); - }); - IntStream.iterate(0,index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); - return result; - } - - private String replacePath(String path,Map params) { - Set> entries = params.entrySet(); - // 替换path中变量 - for (Map.Entry entry : entries) { - String replaceVariables = "{" + entry.getKey() + "}"; - path = StringUtil.replace(path,replaceVariables,entry.getValue()); - } - return path; - } - - public String removeHeadChars(String str, String charsToRemove) { - if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { - return str; - } - while (str.startsWith(charsToRemove)) { - str = str.substring(charsToRemove.length()); - } - return str; - } - - public String removeTailChars(String str, String charsToRemove) { - if (str == null || charsToRemove == null || charsToRemove.isEmpty()) { - return str; - } - while (str.endsWith(charsToRemove)) { - str = str.substring(0, str.length() - charsToRemove.length()); - } - return str; - } -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java deleted file mode 100644 index 5a8d80c..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ParamStrategy.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.service.impl; - -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; -import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; -import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; -import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: huangxing - * @Date: 2024/05/09 08:56 - */ -@Component -@Slf4j -@AllArgsConstructor -@Deprecated -public class ParamStrategy { - - private final IStationVideoTypeClient videoClient; - - /** - * 解析发送参数方式函数 - * @param function 函数 - * @param args 大模型识别参数 - * @return 前端传参EXTRA - */ - public ExtraVO resolve(FunctionEntity function, Map args) { - FuncRouteEnum routeEnum = FuncRouteEnum.getEnumByFuncCode(function.getCode()); - if(Func.isNotEmpty(routeEnum)) { - switch(routeEnum) { - case OPEN_VIDEO: - return this.getVideoExtra(args); - default: - break; - } - } - return null; - } - - public ExtraVO getVideoExtra(Map args) { - // 跳转页面逻辑 - ExtraVO extraVO = new ExtraVO(); - String id = args.get("canvas_id"); - if(StringUtil.isNotBlank(id) && Func.isNotEmpty(id)) { - R videoR = videoClient.getById(Long.valueOf(id)); - if(videoR.isSuccess()) { - StationVideoTypeEntity video = videoR.getData(); - extraVO.setType(FunctionConstants.TypeEnum.PARAMS.getType()); - extraVO.setImmediatelyJump(true); - extraVO.setFunc(FuncRouteEnum.OPEN_VIDEO.getFunc()); - Map params = new HashMap<>(); - params.put("name", video.getName()); - params.put("videoHost", video.getVideoHost()); - params.put("pointCode", video.getPointCode()); - params.put("appKey", video.getAppKey()); - params.put("appSecret", video.getAppSecret()); - params.put("liveSourceAddress",video.getLiveSourceAddress()); - extraVO.setParams(params); - } - } - return extraVO; - } -} 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 b42e0a3..9fd4774 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 @@ -24,11 +24,11 @@ import java.io.Serializable; public class AnswerVO implements Serializable { @ApiModelProperty("发起问答时的随机ID") - @JSONField(name = "id") + @JSONField(name = "chat_id") private String sessionId; @ApiModelProperty("发起问答时的用户ID") - @JSONField(name = "userid") + @JSONField(name = "user_id") private String userId; @ApiModelProperty("1代表代表正在进行问答,0代表已完成") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java index f9661f6..6448893 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java @@ -14,7 +14,7 @@ import java.io.Serializable; @EqualsAndHashCode public class RemoteParamVO implements Serializable { - @JSONField(name = "id") + @JSONField(name = "itemId") private String funcId; @JSONField(name = "yk_name") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java index 888d575..0d54873 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java @@ -1,7 +1,6 @@ package com.hnac.hzims.bigmodel.maintenance.service; -import com.hnac.hzims.bigmodel.datasource.service.DataSourceService; -import lombok.AllArgsConstructor; +import com.hnac.hzims.bigmodel.business.service.DataSourceService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java new file mode 100644 index 0000000..924c12b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java @@ -0,0 +1,106 @@ +package com.hnac.hzims.bigmodel.question.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.hnac.hzims.bigmodel.interactive.vo.SessionContentVO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/10 10:22 + * @Describe: 接收前端发送消息 + */ +@Data +@EqualsAndHashCode +public class MessageDTO implements Serializable { + + /** + * 消息类型 0-心跳消息 1-问题 + */ + private String type; + + /** + * 前端提出问题 + */ + private String context; + + /** + * 前端传参附带参数 + */ + private SessionContentVO content; + + /** + * 是否发起特殊问答 + */ + private Boolean isSpecial; + + /** + * 发起问题用户ID + */ + private String userId; + + /** + * 知识库 + */ + private String knowledge; + + /** + * 会话ID + */ + private String chatId; + + /** + * 选项 + */ + private Object selection; + + /** + * 大模型函数 + */ + private String func; + + /** + * 特殊问题参数 + */ + private Map extra; + + /** + * 是否允许大模型查询数据,默认为1 + */ + @JSONField(name = "enable_record") + private int enableRecord = 1; + + /** + * 是否允许大模型发送指令,默认为1 + */ + @JSONField(name = "enable_yk") + private int enableControl = 1; + + /** + * 是否允许大模型打开视频,默认为1 + */ + @JSONField(name = "enable_video") + private int enableVideo = 1; + + /** + * 是否允许大模型打开画面,默认为1 + */ + @JSONField(name = "enable_canvas") + private int enableCanvas = 1; + + /** + * 是否允许大模型诊断故障,默认为1 + */ + @JSONField(name = "enable_fault") + private int enableFault = 1; + + /** + * 大模型默认的意图理解方式,可以为"default","yk"... + */ + @JSONField(name = "default") + private String defaultMode; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java new file mode 100644 index 0000000..126ec04 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java @@ -0,0 +1,78 @@ +package com.hnac.hzims.bigmodel.question.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Author: huangxing + * @Date: 2024/07/10 10:27 + */ +@Data +@EqualsAndHashCode +public class QuestionDTO implements Serializable { + + /** + * 随机ID,同一个用户的对话使用统一的ID + */ + @JSONField(name = "chat_id") + private String chatId; + + /** + * 用户ID,同一个随机ID只能对应一个用户ID + */ + @JSONField(name = "user_id") + private String userId; + + /** + * 用户的问题 + */ + private String query; + + /** + * 特殊提问内容 + */ + private Map extra; + + private Object data; + + /** + * 是否允许大模型查询数据,默认为 1 + */ + @JSONField(name = "enable_record") + private int enableRecord = 1; + + /** + * 是否允许大模型发送指令,默认为 1 + */ + @JSONField(name = "enable_yk") + private int enableControl = 1; + + /** + * 是否允许大模型打开视频,默认为 1 + */ + @JSONField(name = "enable_video") + private int enableVideo = 1; + + /** + * 是否允许大模型打开画面,默认为 1 + */ + @JSONField(name = "enable_canvas") + private int enableCanvas = 1; + + /** + * 是否允许大模型诊断故障,默认为 1 + */ + @JSONField(name = "enable_fault") + private int enableFault = 1; + + /** + * 大模型默认的意图理解方式,可以为"default","yk"... + */ + @JSONField(name = "default") + private String defaultMode; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java new file mode 100644 index 0000000..6ce56b3 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java @@ -0,0 +1,123 @@ +package com.hnac.hzims.bigmodel.question.service; + +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; +import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; +import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.bigmodel.interactive.vo.ScadaSelectionVO; +import com.hnac.hzims.bigmodel.interactive.vo.VideoSelectionVO; +import com.hnac.hzims.bigmodel.question.dto.MessageDTO; +import com.hnac.hzims.bigmodel.question.dto.QuestionDTO; +import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; +import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.web.socket.TextMessage; + +/** + * @Author: huangxing + * @Date: 2024/07/10 11:03 + */ +@Service +@AllArgsConstructor +public class QuestionHandlerService { + + private final IHznlmInvokeService hznlmInvokeService; + + /** + * 处理用户发起问题 + * @param messageDTO 接收前端消息内容体 + */ + public void handleMessage(MessageDTO messageDTO) { + // 将message转换为question + QuestionDTO question = BeanUtil.copy(messageDTO,QuestionDTO.class); + question.setQuery(messageDTO.getContext()); + // 普通问答 + if(Func.isEmpty(messageDTO.getIsSpecial()) || !messageDTO.getIsSpecial()) { + if (StringUtil.isNotBlank(messageDTO.getKnowledge())) { + hznlmInvokeService.knowledgeAsk(question); + } else { + hznlmInvokeService.ask(question); + } + } else { + FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(messageDTO.getFunc()); + switch (funcEnum) { + case CHOOSE_STATION: + case CHOOSE_YC: + case CHOOSE_FAULT: + case CHOOSE_YK: + question.setData(messageDTO.getSelection()); + hznlmInvokeService.specialAsk(question); + break; + case CHOOSE_VIDEO: + this.handleVideoChoose(messageDTO); + break; + case CHOOSE_CANVAS: + this.handleScadaChoose(messageDTO); + break; + default: + break; + } + } + } + + private void handleVideoChoose(MessageDTO messageDTO) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getSelection(); + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); + String videoId = selection.getItemId(); + ExtraVO videoExtras = resolveService.resolve(videoId); + AnswerVO answerVO = new AnswerVO(); + answerVO.setSessionId(messageDTO.getChatId()); + answerVO.setQuery(selection.getItemName()); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); + answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + catch (Exception e) { + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("视频解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + } + + private void handleScadaChoose(MessageDTO messageDTO) { + InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); + try { + ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getSelection(); + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); + ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); + AnswerVO answerVO = new AnswerVO(); + answerVO.setSessionId(messageDTO.getChatId()); + answerVO.setRunning(0); + answerVO.setStatus(0); + answerVO.setQuery(selection.getItemName()); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); + answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + catch (Exception e) { + AnswerVO answerVO = new AnswerVO(); + answerVO.setRunning(0); + answerVO.setStatus(-2); + answerVO.setAnswer("实时画面解析失败!"); + TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); + wsService.sendMessage(messageDTO.getChatId(),textMessage); + } + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java index be768ed..e861d7a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java @@ -48,7 +48,7 @@ public class FrontEndInteractiveSchedule { private final BladeLogger logger; @XxlJob(GET_INTERACTIVE_RESULT) - public ReturnT getInteractiveResult(String params) { + public ReturnT getInteractiveResult(String params) { List sessionIds = sessionRedisManager.getSessionIds(); if(CollectionUtil.isEmpty(sessionIds)){ XxlJobLogger.log("问题都已经回答完毕!"); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java index ef31b6d..12ed989 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -19,14 +19,15 @@ import java.util.Map; @Slf4j public class RequestClientUtil { + /** * 无返回结果远程调用http接口 * @param url 接口url * @param body 传参body */ - public static void postCall(String url, Map body) { + public static void postCall(String url, String body) { log.info("开始远程调用{}接口",url); - HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + HttpResponse response = HttpRequest.post(url).body(body).execute(); log.info("远程调用{}接口结束",url); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用接口" + url + "失败!"); @@ -34,6 +35,19 @@ public class RequestClientUtil { } /** + * 无返回结果远程调用http接口 + * @param url 接口url + * @param body 传参body + */ + public static void postCall(String url, Map body) { + log.info("开始远程调用{}接口",url); + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();log.info("远程调用{}接口结束",url); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + throw new ServiceException("远程调用接口" + url + "失败!"); + }); + } + + /** * 远程调用http接口 * @param url 接口url * @param body 传参 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 2c76eb5..ba93fb4 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 @@ -2,19 +2,17 @@ package com.hnac.hzims.bigmodel.websocket.handler; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.factory.ResolveFactory; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; -import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; -import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; +import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import com.hnac.hzims.bigmodel.interactive.vo.*; -import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.question.dto.MessageDTO; +import com.hnac.hzims.bigmodel.question.service.QuestionHandlerService; import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +24,6 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; -import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -64,8 +61,8 @@ public class InteractiveHandler extends TextWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) { - JSONObject messageJSON = JSONObject.parseObject(message.getPayload()); - if("0".equals(messageJSON.getString("type"))) { + MessageDTO messageDTO = JSONObject.parseObject(message.getPayload(), MessageDTO.class); + if("0".equals(messageDTO.getType())) { // 接收心跳消息,返回一条心跳消息 try { session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息")); @@ -73,14 +70,33 @@ public class InteractiveHandler extends TextWebSocketHandler { throw new RuntimeException(e); } } else { - String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); - if(messageJSON.containsKey("content")) { - // 将发送参数存入redis + String chatId = InteractiveSessionManager.getEntryBySession(session).getKey(); + messageDTO.setChatId(chatId); + // 将发送参数存入redis + if(Func.isNotEmpty(messageDTO.getContent())) { redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); - redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); + redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,chatId,messageDTO.getContent()); } - this.handleMessage(messageJSON, sessionId); + QuestionHandlerService service = SpringUtil.getBean(QuestionHandlerService.class); + service.handleMessage(messageDTO); } +// 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 sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); +// if(messageJSON.containsKey("content")) { +// // 将发送参数存入redis +// redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); +// redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); +// } +// this.handleMessage(messageJSON, sessionId); +// } } private void handleMessage(JSONObject messageContext, String sessionId) { @@ -129,18 +145,16 @@ public class InteractiveHandler extends TextWebSocketHandler { private void handleVideoChoose(JSONObject messageContext,String sessionId) { InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); try { - ParamStrategy strategy = SpringUtil.getBean(ParamStrategy.class); VideoSelectionVO selection = messageContext.getObject("selection", VideoSelectionVO.class); - String videoId = selection.getId(); - Map param = new HashMap<>(1); - param.put("canvas_id",videoId); - ExtraVO videoExtras = strategy.getVideoExtra(param); + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); + String videoId = selection.getItemId(); + ExtraVO videoExtras = resolveService.resolve(videoId); AnswerVO answerVO = new AnswerVO(); answerVO.setSessionId(sessionId); - answerVO.setQuery(selection.getName()); + answerVO.setQuery(selection.getItemName()); answerVO.setRunning(0); answerVO.setStatus(0); - answerVO.setAnswer("已成功打开"+selection.getName()+"视频"); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); wsService.sendMessage(sessionId,textMessage); @@ -158,19 +172,15 @@ public class InteractiveHandler extends TextWebSocketHandler { private void handleScadaChoose(JSONObject messageContext,String sessionId) { InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); try { - JumpRouteJoinStrategy strategy = SpringUtil.getBean(JumpRouteJoinStrategy.class); ScadaSelectionVO selection = messageContext.getObject("selection", ScadaSelectionVO.class); - Map param = new HashMap<>(1); - param.put("canvas_id",selection.getId()); - IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); - FunctionEntity function = functionService.getFunctionByCode(FuncRouteEnum.OPEN_CANVAS.getFunc()); - ExtraVO scadaExtra = strategy.getScadaExtra(param, function); + IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); + ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); AnswerVO answerVO = new AnswerVO(); answerVO.setSessionId(sessionId); answerVO.setRunning(0); answerVO.setStatus(0); - answerVO.setQuery(selection.getName()); - answerVO.setAnswer("已成功打开"+selection.getName()+"实时画面"); + answerVO.setQuery(selection.getItemName()); + answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); wsService.sendMessage(sessionId,textMessage); From 9a87d6550cd34e20c74c7fc2e30fe9aca30204bd Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 11 Jul 2024 15:04:22 +0800 Subject: [PATCH 150/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java | 2 +- .../hzims/bigmodel/interactive/factory/ResolveFactory.java | 3 --- .../interactive/service/impl/CanvasResolveServiceImpl.java | 2 +- .../service/impl/ChoiceAnswerResolveServiceImpl.java | 6 +----- .../bigmodel/maintenance/controller/DataSourceController.java | 11 ++++++++++- .../maintenance/controller/TablePropertyController.java | 2 +- .../bigmodel/maintenance/service/TableColumnService.java | 6 +++--- .../java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java | 5 ----- .../com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java | 2 -- .../bigmodel/question/service/QuestionHandlerService.java | 5 ++--- .../java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java | 3 ++- 11 files changed, 21 insertions(+), 26 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java index c864829..d9be4d7 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/ExtraVO.java @@ -45,7 +45,7 @@ public class ExtraVO implements Serializable { @ApiModelProperty("选项") @JsonInclude(JsonInclude.Include.NON_NULL) - private List selection; + private List data; @JSONField(name = "agent_name") private String agentName; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java index b3fafc6..6f7a632 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/ResolveFactory.java @@ -1,9 +1,6 @@ package com.hnac.hzims.bigmodel.interactive.factory; -import com.hnac.hzims.bigmodel.entity.FunctionEntity; -import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; -import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.service.IResolveService; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java index c4b8f74..6b7f247 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/CanvasResolveServiceImpl.java @@ -52,7 +52,7 @@ public class CanvasResolveServiceImpl implements IResolveService { ExtraVO extraVO = new ExtraVO(); extraVO.setImmediatelyJump(true); extraVO.setFunc(FuncRouteEnum.OPEN_CANVAS.getFunc()); - final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","itemId"}; + final String[] SCADA_PARAMS_SOLVE = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; String canvasHost = ParamCache.getValue(ParamKeyConstants.CANVAS_HOST); // 将ID解析为 Map resolveMap = this.resolve(id, SCADA_PARAMS_SOLVE); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java index 568bd50..f6495f1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ChoiceAnswerResolveServiceImpl.java @@ -37,11 +37,7 @@ public class ChoiceAnswerResolveServiceImpl implements IAnswerResolveService { public ExtraVO getExtra(JSONObject originExtra) { ExtraVO result = JSONObject.parseObject(JSON.toJSONString(originExtra),ExtraVO.class); result.setSpecial(true); - String funcCode = originExtra.getString("func"); - result.setFunc(funcCode); - result.setType(FuncRouteEnum.getEnumByFuncCode(funcCode).getType().getType()); - JSONArray selections = JSONArray.parseArray(JSON.toJSONString(originExtra.get("data"))); - result.setSelection(selections); + result.setType(FuncRouteEnum.getEnumByFuncCode(result.getFunc()).getType().getType()); return result; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java index 656910e..91989c1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/DataSourceController.java @@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * @Author: huangxing * @Date: 2024/07/05 16:55 @@ -37,7 +39,7 @@ public class DataSourceController { } @GetMapping("/detail") - @ApiOperation(value = "分页查询") + @ApiOperation(value = "查看详情") @ApiOperationSupport(order = 2) public R detail(@RequestParam @ApiParam("主键ID") Long id) { return R.data(dataSourceService.getById(id)); @@ -64,4 +66,11 @@ public class DataSourceController { return R.status(dataSourceService.updateById(req)); } + @GetMapping("/list") + @ApiOperation(value = "列表查询") + @ApiOperationSupport(order = 1) + public R> list(DatasourceEntity req) { + return R.data(dataSourceService.list(Condition.getQueryWrapper(req).lambda())); + } + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java index 88412f0..1961bef 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/TablePropertyController.java @@ -36,7 +36,7 @@ public class TablePropertyController { } @GetMapping("/detail") - @ApiOperation(value = "分页查询") + @ApiOperation(value = "查看详情") @ApiOperationSupport(order = 2) public R detail(@RequestParam @ApiParam("主键ID") Long id) { return R.data(tablePropertyService.getById(id)); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java index 0d54873..91f04fb 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/TableColumnService.java @@ -20,17 +20,17 @@ public class TableColumnService { private final DataSourceService dataSourceService; public List> getDatabase(String datasource) { - String sql = "select distinct `table_schema` from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; + String sql = "select distinct `table_schema` as tableName from `information_schema`.`tables` where `table_schema` <> 'information_schema';"; return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } public List> getTables(String datasource,String database) { - String sql = "select distinct `table_name` from `information_schema`.`tables` where `table_schema` = '" + database + "';"; + String sql = "select distinct `table_name` as tableName from `information_schema`.`tables` where `table_schema` = '" + database + "';"; return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } public List> getColumns(String datasource,String database,String tableName) { - String sql = "select distinct `column_name`,`column_comment` from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; + String sql = "select distinct `column_name` as columnName,`column_comment` as columnComment from `information_schema`.`COLUMNS` where `TABLE_SCHEMA` = '" + database + "' and `TABLE_NAME` = '" + tableName + "';"; return dataSourceService.queryListOnSpecificDataSource(sql,datasource); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java index 924c12b..6f2c729 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/MessageDTO.java @@ -53,11 +53,6 @@ public class MessageDTO implements Serializable { private String chatId; /** - * 选项 - */ - private Object selection; - - /** * 大模型函数 */ private String func; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java index 126ec04..d01369e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/dto/QuestionDTO.java @@ -37,8 +37,6 @@ public class QuestionDTO implements Serializable { */ private Map extra; - private Object data; - /** * 是否允许大模型查询数据,默认为 1 */ diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java index 6ce56b3..1b1ee84 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java @@ -53,7 +53,6 @@ public class QuestionHandlerService { case CHOOSE_YC: case CHOOSE_FAULT: case CHOOSE_YK: - question.setData(messageDTO.getSelection()); hznlmInvokeService.specialAsk(question); break; case CHOOSE_VIDEO: @@ -71,7 +70,7 @@ public class QuestionHandlerService { private void handleVideoChoose(MessageDTO messageDTO) { InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); try { - VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getSelection(); + VideoSelectionVO selection = (VideoSelectionVO) messageDTO.getExtra().get("data"); IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); String videoId = selection.getItemId(); ExtraVO videoExtras = resolveService.resolve(videoId); @@ -98,7 +97,7 @@ public class QuestionHandlerService { private void handleScadaChoose(MessageDTO messageDTO) { InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); try { - ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getSelection(); + ScadaSelectionVO selection = (ScadaSelectionVO) messageDTO.getExtra().get("data"); IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); AnswerVO answerVO = new AnswerVO(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java index 12ed989..f456c65 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/utils/RequestClientUtil.java @@ -41,7 +41,8 @@ public class RequestClientUtil { */ public static void postCall(String url, Map body) { log.info("开始远程调用{}接口",url); - HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();log.info("远程调用{}接口结束",url); + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + log.info("远程调用{}接口结束",url); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用接口" + url + "失败!"); }); From 6b51668db20f76a2dfcd13c98040cd3ecb30f398 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 11 Jul 2024 17:09:06 +0800 Subject: [PATCH 151/151] =?UTF-8?q?fix=EF=BC=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/bigmodel/question/service/QuestionHandlerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java index 1b1ee84..a9c168e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/question/service/QuestionHandlerService.java @@ -47,7 +47,7 @@ public class QuestionHandlerService { hznlmInvokeService.ask(question); } } else { - FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(messageDTO.getFunc()); + FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode((String) messageDTO.getExtra().get("func")); switch (funcEnum) { case CHOOSE_STATION: case CHOOSE_YC: