From 9ac0ad8f44b78c0ef9a4570c3e10ae80ced6b82f Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 28 Nov 2022 10:23:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=89=80=E6=9C=89=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrainingV2PublishController.java | 16 ++++++- .../training2/Training2PublishService.java | 44 +++++++++---------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java index 10d313ee2..001e0fe17 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java @@ -1,6 +1,7 @@ package club.joylink.rtss.controller.training2; import club.joylink.rtss.services.training2.Training2PublishService; +import club.joylink.rtss.services.training2.Training2TypeEnum; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.training2.publish.*; import lombok.extern.slf4j.Slf4j; @@ -47,20 +48,31 @@ public class TrainingV2PublishController { public DeletePublishedTraining2RspVo deletePublishedTrainings(@RequestBody DeletePublishedTraining2ReqVo req){ return this.publishService.deletePublishedTrainings(req); } + /** * 根据mapId查所有的已发布单操实训的基础信息 */ @GetMapping("/{mapId}/singles") - public List findAllSingleTrainingBasicInfo(@PathVariable("mapId") Long mapId){ + public List findSingleTrainingBasicInfo(@PathVariable("mapId") Long mapId){ return this.publishService.findAllSingleTrainingBasicInfoByMapId(mapId); } + /** * 根据mapId查所有的已发布场景实训的基础信息 */ @GetMapping("/{mapId}/scenes") - public List findAllSceneTrainingBasicInfo(@PathVariable("mapId") Long mapId){ + public List findSceneTrainingBasicInfo(@PathVariable("mapId") Long mapId){ return this.publishService.findAllSceneTrainingBasicInfoByMapId(mapId); } + + /** + * 查所有的已发布场景实训的基础信息 + */ + @GetMapping("/list") + public List findTrainingList(Long mapId,Training2TypeEnum type){ + return this.publishService.findTrainingInfo(mapId, type); + } + /** * 根据实训id查该已发布实训的所有信息 */ diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java index f9c5ff6c5..85057baad 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java @@ -19,6 +19,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 已发布实训管理业务实现 @@ -202,18 +203,7 @@ public class Training2PublishService { */ @Transactional(readOnly = true) public List findAllSingleTrainingBasicInfoByMapId(Long mapId) { - List rsp = new ArrayList<>(); - // - PublishedTraining2Example example = new PublishedTraining2Example(); - example.createCriteria().andMapIdEqualTo(mapId).andTypeEqualTo(Training2TypeEnum.single.value()); - List list = this.publishedDao.selectByExample(example); - if (!CollectionUtils.isEmpty(list)) { - list.forEach(p -> { - rsp.add(Training2Convertor.convertFrom(p)); - }); - } - // - return rsp; + return findTrainingInfo(mapId, Training2TypeEnum.single); } /** @@ -221,18 +211,28 @@ public class Training2PublishService { */ @Transactional(readOnly = true) public List findAllSceneTrainingBasicInfoByMapId(Long mapId) { - List rsp = new ArrayList<>(); - // + return findTrainingInfo(mapId, Training2TypeEnum.scene); + } + + + /** + * 根据地图ID和类型查询实训列表 + */ + public List findTrainingInfo(Long mapId, Training2TypeEnum type) { PublishedTraining2Example example = new PublishedTraining2Example(); - example.createCriteria().andMapIdEqualTo(mapId).andTypeEqualTo(Training2TypeEnum.scene.value()); - List list = this.publishedDao.selectByExample(example); - if (!CollectionUtils.isEmpty(list)) { - list.forEach(p -> { - rsp.add(Training2Convertor.convertFrom(p)); - }); + PublishedTraining2Example.Criteria criteria = example.createCriteria(); + if (mapId != null) { + criteria.andMapIdEqualTo(mapId); + } + if (type != null) { + criteria.andTypeEqualTo(type.value()); + } + List list = this.publishedDao.selectByExample(example); + if (CollectionUtils.isEmpty(list)) { + return List.of(); + } else { + return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList()); } - // - return rsp; } /** From 753ad674f4119d4007e3bf26081eb48bdd4edd0d Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 28 Nov 2022 10:46:33 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E3=80=90=E5=8F=96=E6=B6=88=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E6=9D=A1=E6=95=B0=E9=99=90=E5=88=B6?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/entity/project/ProjectExample.java | 70 ------------------- .../services/org/OrgUserManageService.java | 1 - 2 files changed, 71 deletions(-) diff --git a/src/main/java/club/joylink/rtss/entity/project/ProjectExample.java b/src/main/java/club/joylink/rtss/entity/project/ProjectExample.java index ff5f4ddd2..00e1ae3c1 100644 --- a/src/main/java/club/joylink/rtss/entity/project/ProjectExample.java +++ b/src/main/java/club/joylink/rtss/entity/project/ProjectExample.java @@ -394,76 +394,6 @@ public class ProjectExample { addCriterion("`status` not between", value1, value2, "status"); return (Criteria) this; } - - public Criteria andViewShowIsNull() { - addCriterion("`view_show` is null"); - return (Criteria) this; - } - - public Criteria andViewShowIsNotNull() { - addCriterion("`view_show` is not null"); - return (Criteria) this; - } - - public Criteria andViewShowEqualTo(Integer value) { - addCriterion("`view_show` =", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowNotEqualTo(Integer value) { - addCriterion("`view_show` <>", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowGreaterThan(Integer value) { - addCriterion("`view_show` >", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowGreaterThanOrEqualTo(Integer value) { - addCriterion("`view_show` >=", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowLessThan(Integer value) { - addCriterion("`view_show` <", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowLessThanOrEqualTo(Integer value) { - addCriterion("`view_show` <=", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowLike(Integer value) { - addCriterion("`view_show` like", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowNotLike(Integer value) { - addCriterion("`view_show` not like", value, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowIn(List values) { - addCriterion("`view_show` in", values, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowNotIn(List values) { - addCriterion("`view_show` not in", values, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowBetween(Integer value1, Integer value2) { - addCriterion("`view_show` between", value1, value2, "viewShow"); - return (Criteria) this; - } - - public Criteria andViewShowNotBetween(Integer value1, Integer value2) { - addCriterion("`view_show` not between", value1, value2, "viewShow"); - return (Criteria) this; - } } /** diff --git a/src/main/java/club/joylink/rtss/services/org/OrgUserManageService.java b/src/main/java/club/joylink/rtss/services/org/OrgUserManageService.java index e1538bb0b..0c7b45e87 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgUserManageService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgUserManageService.java @@ -57,7 +57,6 @@ public class OrgUserManageService { if (StringUtils.hasText(queryVO.getName())) { criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); } - example.setLimit(10); List sysAccounts = sysAccountDAO.selectByExample(example); if (CollectionUtils.isEmpty(sysAccounts)) { return new ArrayList<>(); From 6552caaec22b6dd5ac17c55cbd4a879bbf2cb3be Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 28 Nov 2022 11:00:47 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E3=80=90=E6=9F=A5=E8=AF=A2=E6=9C=89?= =?UTF-8?q?=E6=95=88=E7=9A=84=E7=BB=84=E7=BB=87=E4=BF=A1=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mybatis/mapper/OrgUserDAO.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mybatis/mapper/OrgUserDAO.xml b/src/main/resources/mybatis/mapper/OrgUserDAO.xml index b529f4ea7..4bfa4b2cb 100644 --- a/src/main/resources/mybatis/mapper/OrgUserDAO.xml +++ b/src/main/resources/mybatis/mapper/OrgUserDAO.xml @@ -275,7 +275,7 @@ FROM org_user os LEFT JOIN org o ON o.id = os.org_id LEFT JOIN org ro ON o.root_id = ro.id - WHERE os.user_id = #{userId} + WHERE os.user_id = #{userId} and o.status = 1 From 6bbda91f08e67e8919fad54a9bc37cfc6f41eb79 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 28 Nov 2022 14:10:15 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=BA=94=E6=80=A5=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/client/StompClientManager2.java | 59 ---------------- .../rtss/services/ws/EnvLoggerFileTest.java} | 12 ++-- .../joylink/rtss/services/ws/StompTest.java} | 67 +++++++++++++++---- 3 files changed, 58 insertions(+), 80 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java rename src/{main/java/club/joylink/rtss/util/test/LogTest.java => test/java/club/joylink/rtss/services/ws/EnvLoggerFileTest.java} (90%) rename src/{main/java/club/joylink/rtss/websocket/client/StompClientManager.java => test/java/club/joylink/rtss/services/ws/StompTest.java} (69%) diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java deleted file mode 100644 index aeb47834a..000000000 --- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java +++ /dev/null @@ -1,59 +0,0 @@ -package club.joylink.rtss.websocket.client; - -import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.util.test.LogTest; -import club.joylink.rtss.vo.ws.TrainPosition; -import lombok.extern.slf4j.Slf4j; -import org.springframework.messaging.simp.stomp.StompFrameHandler; -import org.springframework.messaging.simp.stomp.StompHeaders; -import org.springframework.messaging.simp.stomp.StompSession; -import org.springframework.util.concurrent.ListenableFuture; -import org.springframework.web.socket.client.standard.StandardWebSocketClient; -import org.springframework.web.socket.messaging.WebSocketStompClient; - -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Type; -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - -@Slf4j -public class StompClientManager2 { - - public static void main(String[] args) throws ExecutionException, InterruptedException { - StandardWebSocketClient socketClient = new StandardWebSocketClient(); - WebSocketStompClient stompClient = new WebSocketStompClient(socketClient); - SimulationSessionHandler handler = new SimulationSessionHandler(); - ListenableFuture future = stompClient - .connect("ws://127.0.0.1:9000/joylink-websocket?token=6a8dbf62d3683844a6aa722b73b989f1",handler, "null"); - StompSession stompSession = future.get(); - stompSession.subscribe("/topic/yjddzh/trainPosition", new StompFrameHandler() { - @Override - public Type getPayloadType(StompHeaders stompHeaders) { - return byte[].class; - } - - @Override - public void handleFrame(StompHeaders stompHeaders, Object o) { - String recv=null; - try { - recv = new String((byte[]) o,"UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - System.out.println(recv); - } - }); - stompSession.setAutoReceipt(true); - TimeUnit.SECONDS.sleep(100); - } - - -} diff --git a/src/main/java/club/joylink/rtss/util/test/LogTest.java b/src/test/java/club/joylink/rtss/services/ws/EnvLoggerFileTest.java similarity index 90% rename from src/main/java/club/joylink/rtss/util/test/LogTest.java rename to src/test/java/club/joylink/rtss/services/ws/EnvLoggerFileTest.java index cbe641467..76ff0d90a 100644 --- a/src/main/java/club/joylink/rtss/util/test/LogTest.java +++ b/src/test/java/club/joylink/rtss/services/ws/EnvLoggerFileTest.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.util.test; +package club.joylink.rtss.services.ws; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.util.JsonUtils; @@ -16,14 +16,12 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -public class LogTest { - - +public class EnvLoggerFileTest { public static void main(String[] args) throws FileNotFoundException { - LogTest lt = new LogTest(); + EnvLoggerFileTest lt = new EnvLoggerFileTest(); List list = lt.readFile("d:\\spring.log2"); // lt.query(list,"024"); - list = lt.query(list,"015",Section.SectionRoadType.RIGHT); + list = lt.query(list,"015", Section.SectionRoadType.RIGHT); for (TrainPosition tp : list) { System.out.println(tp.dateFormat() + " --->" + tp.toString()); } @@ -52,7 +50,7 @@ public class LogTest { return newList; } public List query(List list, String groupNum, Section.SectionRoadType roadType){ - List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList()); + List newList = list.stream().filter(d-> Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList()); return newList; } public List query(List list,String groupNum){ diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/test/java/club/joylink/rtss/services/ws/StompTest.java similarity index 69% rename from src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java rename to src/test/java/club/joylink/rtss/services/ws/StompTest.java index a42c0c740..e87a4fc8b 100644 --- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java +++ b/src/test/java/club/joylink/rtss/services/ws/StompTest.java @@ -1,18 +1,20 @@ -package club.joylink.rtss.websocket.client; +package club.joylink.rtss.services.ws; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.util.JsonUtils; - import club.joylink.rtss.util.test.LogTest; import club.joylink.rtss.vo.ws.TrainPosition; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; -import lombok.extern.slf4j.Slf4j; +import club.joylink.rtss.websocket.client.SimulationSessionHandler; +import org.junit.jupiter.api.Test; +import org.springframework.messaging.simp.stomp.StompFrameHandler; +import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.messaging.WebSocketStompClient; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.time.Instant; import java.time.LocalDateTime; @@ -24,28 +26,66 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -@Slf4j -public class StompClientManager { - -// private static final Map stompClientMap = new ConcurrentHashMap<>(); - - public static void main(String[] args) throws ExecutionException, InterruptedException { +public class StompTest { + @Test + public void sendMsg(){ StandardWebSocketClient socketClient = new StandardWebSocketClient(); WebSocketStompClient stompClient = new WebSocketStompClient(socketClient); SimulationSessionHandler handler = new SimulationSessionHandler(); ListenableFuture future = stompClient .connect("ws://127.0.0.1:9000/joylink-tbi-websocket?user_account=train_place&account_pwd=train_place",handler, "null"); - StompSession stompSession = future.get(); + StompSession stompSession = null; + try { + stompSession = future.get(); + } catch (Exception e) { + e.printStackTrace(); + } LogTest lt = new LogTest(); List list = lt.readFile("d:\\spring.log2"); // List list = lt.readSource("d:\\t.txt"); // runToLeft(stompSession,"001"); // runToRight(stompSession,"002"); - list = lt.query(list,"004",Section.SectionRoadType.LEFT); + list = lt.query(list,"004", Section.SectionRoadType.LEFT); // list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT); send(stompSession,list); } + @Test + public void subscribe(){ + StandardWebSocketClient socketClient = new StandardWebSocketClient(); + WebSocketStompClient stompClient = new WebSocketStompClient(socketClient); + SimulationSessionHandler handler = new SimulationSessionHandler(); + ListenableFuture future = stompClient + .connect("ws://127.0.0.1:9000/joylink-websocket?token=6a8dbf62d3683844a6aa722b73b989f1",handler, "null"); + StompSession stompSession = null; + try { + stompSession = future.get(); + } catch (Exception e) { + e.printStackTrace(); + } + stompSession.subscribe("/topic/yjddzh/trainPosition", new StompFrameHandler() { + @Override + public Type getPayloadType(StompHeaders stompHeaders) { + return byte[].class; + } + @Override + public void handleFrame(StompHeaders stompHeaders, Object o) { + String recv=null; + try { + recv = new String((byte[]) o,"UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + System.out.println(recv); + } + }); + stompSession.setAutoReceipt(true); + try { + TimeUnit.SECONDS.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } public static void send(StompSession stompSession,List list){ for (int i = 25; i < list.size(); i++) { @@ -118,5 +158,4 @@ public class StompClientManager { } } } - } From e628916d5215795e20911cebc42723cece22b3e1 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 28 Nov 2022 14:55:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=BA=94=E6=80=A5=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/controller/paper/PaperCompositionController.java | 2 +- src/test/java/club/joylink/rtss/services/ws/StompTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/paper/PaperCompositionController.java b/src/main/java/club/joylink/rtss/controller/paper/PaperCompositionController.java index dfec2f91c..7c231facf 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PaperCompositionController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PaperCompositionController.java @@ -31,7 +31,7 @@ public class PaperCompositionController { * @return */ @Role(value = RoleEnum.SuperAdmin) - @GetMapping(path = "/manage/paging") + @PostMapping(path = "/manage/paging") public PageVO findPaperCompositionForPage(@RequestBody FindPaperCompositionPageReqVo req) { return this.compositionService.findPaperCompositionByPage(req); } diff --git a/src/test/java/club/joylink/rtss/services/ws/StompTest.java b/src/test/java/club/joylink/rtss/services/ws/StompTest.java index e87a4fc8b..0a7e018c4 100644 --- a/src/test/java/club/joylink/rtss/services/ws/StompTest.java +++ b/src/test/java/club/joylink/rtss/services/ws/StompTest.java @@ -2,7 +2,6 @@ package club.joylink.rtss.services.ws; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.util.test.LogTest; import club.joylink.rtss.vo.ws.TrainPosition; import club.joylink.rtss.websocket.client.SimulationSessionHandler; import org.junit.jupiter.api.Test; @@ -40,7 +39,7 @@ public class StompTest { } catch (Exception e) { e.printStackTrace(); } - LogTest lt = new LogTest(); + EnvLoggerFileTest lt = new EnvLoggerFileTest(); List list = lt.readFile("d:\\spring.log2"); // List list = lt.readSource("d:\\t.txt"); // runToLeft(stompSession,"001");