From 6cac955c4c6cc664ccf6af54431d2f54848ffeb9 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 30 Dec 2020 16:17:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=9B=BD=E8=B5=9B=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompetitionPracticalController.java | 17 +++++- .../permission/GoodsController.java | 4 +- .../joylink/rtss/services/GoodsService.java | 6 +- .../joylink/rtss/services/IGoodsService.java | 4 +- .../rtss/services/IPermissionService.java | 2 + .../joylink/rtss/services/OrderService.java | 46 ++++++++------ .../rtss/services/OrganizationService.java | 2 + .../rtss/services/PermissionService.java | 16 +++++ .../rtss/services/UserPermissionService.java | 15 ++--- .../CompetitionPracticalService.java | 61 ++++++++++++++++++- .../ICompetitionPracticalService.java | 15 ++++- .../student/ClassStudentUserServiceImpl.java | 2 +- 12 files changed, 146 insertions(+), 44 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java b/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java index e05729e1c..4ff3f96c2 100644 --- a/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java +++ b/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java @@ -1,10 +1,9 @@ package club.joylink.rtss.controller.competition; -import com.fasterxml.jackson.annotation.JsonView; -import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.entity.CompetitionWithBLOBs; import club.joylink.rtss.services.completition.ICompetitionPracticalService; +import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; @@ -12,8 +11,10 @@ import club.joylink.rtss.vo.client.competition.CompetitionPagedQueryVO; import club.joylink.rtss.vo.client.competition.CompetitionResult; import club.joylink.rtss.vo.client.competition.CompetitionVO; import club.joylink.rtss.vo.client.competition.OperationStatisticVO; +import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; import club.joylink.rtss.vo.client.validGroup.competition.CompetitionUpdateCheck; import club.joylink.rtss.vo.view.OperationStatisticAnswerView; +import com.fasterxml.jackson.annotation.JsonView; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -88,6 +89,18 @@ public class CompetitionPracticalController { iCompetitionPracticalService.importFromJson(scriptId, name, competition); } + @ApiOperation("查询权限") + @GetMapping("/query/permissions") + public UserPermissionVO queryPermissions(Long mapId, @RequestAttribute UserVO user) { + return iCompetitionPracticalService.queryPermissions(mapId, user); + } + + @ApiOperation("购买权限") + @PostMapping("/purchasePermission") + public String purchasePermission(Long mapId, Long amount, @RequestAttribute UserVO user) { + return iCompetitionPracticalService.purchasePermission(mapId, amount, user); + } + /* ------------------------- 竞赛运行相关 ------------------------- */ @ApiOperation("加载竞赛场景") @PutMapping("/load/{group}/{id}") diff --git a/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java b/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java index 2453dd2c8..916dce315 100644 --- a/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java +++ b/src/main/java/club/joylink/rtss/controller/permission/GoodsController.java @@ -40,7 +40,7 @@ public class GoodsController { @ApiOperation(value = "查询商品详情") @GetMapping(path = "/{id}") public GoodsVO selectById(@PathVariable long id) { - return iGoodsService.selectById(id); + return iGoodsService.queryById(id); } @ApiOperation(value = "获取有效商品列表") @@ -100,7 +100,7 @@ public class GoodsController { @ApiOperation(value = "根据权限id查询商品") @GetMapping(path = "/permissionId") public GoodsVO selectGoodsByPermissionId(Long permissionId) { - return iGoodsService.selectGoodsByPermissionId(permissionId); + return iGoodsService.queryGoodsByPermissionId(permissionId); } @ApiOperation(value = "根据权限ids查询权限包商品") diff --git a/src/main/java/club/joylink/rtss/services/GoodsService.java b/src/main/java/club/joylink/rtss/services/GoodsService.java index fbae7d449..dc320cefd 100644 --- a/src/main/java/club/joylink/rtss/services/GoodsService.java +++ b/src/main/java/club/joylink/rtss/services/GoodsService.java @@ -93,7 +93,7 @@ public class GoodsService implements IGoodsService { * 根据id查询商品。 */ @Override - public GoodsVO selectById(long id) { + public GoodsVO queryById(long id) { SaleGoods goods = findEntity(id); if (goods == null) { return null; @@ -131,7 +131,7 @@ public class GoodsService implements IGoodsService { * 如果不存在,return一个只有permissionName和permissionType的GoodsVO */ @Override - public GoodsVO selectGoodsByPermissionId(Long permissionId) { + public GoodsVO queryGoodsByPermissionId(Long permissionId) { SaleGoodsExample example = new SaleGoodsExample(); example.createCriteria() .andPermissionIdEqualTo(permissionId); @@ -160,7 +160,7 @@ public class GoodsService implements IGoodsService { return null; } PermissionVO perVO = voList.get(0); - GoodsVO goodsVO = selectGoodsByPermissionId(voList.get(0).getId()); + GoodsVO goodsVO = queryGoodsByPermissionId(voList.get(0).getId()); if (goodsVO == null) { goodsVO = new GoodsVO(); goodsVO.setPermissionId(perVO.getId()); diff --git a/src/main/java/club/joylink/rtss/services/IGoodsService.java b/src/main/java/club/joylink/rtss/services/IGoodsService.java index c71dac3bb..4ac657417 100644 --- a/src/main/java/club/joylink/rtss/services/IGoodsService.java +++ b/src/main/java/club/joylink/rtss/services/IGoodsService.java @@ -23,7 +23,7 @@ public interface IGoodsService { /** * 查询商品详情 */ - GoodsVO selectById(long id); + GoodsVO queryById(long id); /** * 更新商品 @@ -43,7 +43,7 @@ public interface IGoodsService { /** * 根据权限id查询商品 */ - GoodsVO selectGoodsByPermissionId(Long permissionId); + GoodsVO queryGoodsByPermissionId(Long permissionId); /** * 通过关联权限ids查询权限包商品 diff --git a/src/main/java/club/joylink/rtss/services/IPermissionService.java b/src/main/java/club/joylink/rtss/services/IPermissionService.java index f2d80d8e6..db8986d0a 100644 --- a/src/main/java/club/joylink/rtss/services/IPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/IPermissionService.java @@ -62,4 +62,6 @@ public interface IPermissionService { * @return */ List getJointAndTeachEntities(List mapIds); + + Permission findJointSimulationEntity(Long mapId); } diff --git a/src/main/java/club/joylink/rtss/services/OrderService.java b/src/main/java/club/joylink/rtss/services/OrderService.java index 6a8fcd29a..b98010291 100644 --- a/src/main/java/club/joylink/rtss/services/OrderService.java +++ b/src/main/java/club/joylink/rtss/services/OrderService.java @@ -28,7 +28,6 @@ import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; @Service @@ -110,13 +109,11 @@ public class OrderService implements IOrderService { @Override @Transactional public String createOrder(OrderCreateVO createVO, UserVO user) { - if (valid(createVO)) { - return create(createVO, user); - } - return null; + return create(createVO, user); } private String create(OrderCreateVO createVO, UserVO user) { + confirmCorrect(createVO); //新增订单 SaleOrder saleOrder = createVO.convert2DB(); saleOrder.setCode(iOrderNoGenerator.next()); @@ -144,20 +141,35 @@ public class OrderService implements IOrderService { return saleOrder.getCode(); } - private boolean valid(OrderCreateVO createVO) { + /** + * 确认订单参数正确 + */ + private void confirmCorrect(OrderCreateVO createVO) { SaleOrderTypeEnum type = SaleOrderTypeEnum.getSaleOrderTypeByCode(createVO.getOrderType()); switch (type) { case Business_Contract: - Objects.requireNonNull(createVO.getOrganizationId()); - Objects.requireNonNull(createVO.getContractNo()); - Objects.requireNonNull(createVO.getSellerId()); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(iOrganizationService.isExist(createVO.getOrganizationId()), - "没有该组织机构/企业"); - BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotNull(isContractNoExist(createVO.getContractNo()), - String.format("合同编号为[%s]的订单已存在", createVO.getContractNo())); +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getOrganizationId(), "订单组织/单位不能为空"); +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getContractNo(), "订单合同号不能为空"); +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getSellerId(), "订单销售人员不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getForever(), "订单是否永久不能不填"); + if (createVO.getOrganizationId() != null) { + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(iOrganizationService.isExist(createVO.getOrganizationId()), + "没有该组织机构/企业"); + } + if (createVO.getContractNo() != null) { + BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(isContractNoExist(createVO.getContractNo()), + String.format("合同编号为[%s]的订单已存在", createVO.getContractNo())); + } + if (!createVO.getForever()) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getStartTime(), "非永久订单开始时间不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getMonthAmount(), "非永久订单购买时长不能为空"); + } + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getPrice(), "订单总价不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getPayWays(), "订单支付方式不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getPayStatus(), "订单支付状态不能为空"); break; case Contract_Gift: - Objects.requireNonNull(createVO.getOrganizationId()); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getOrganizationId(), "订单组织/单位不能为空"); break; } //公共校验 @@ -179,7 +191,6 @@ public class OrderService implements IOrderService { detailVO.getGoodsAmount() != null && detailVO.getGoodsAmount() > 0, "商品数量至少为1"); } - return true; } /** @@ -244,10 +255,7 @@ public class OrderService implements IOrderService { public boolean isContractNoExist(String contractNo) { SaleOrderExample example = new SaleOrderExample(); example.createCriteria().andContractNoEqualTo(contractNo); - if (saleOrderDAO.countByExample(example) == 0) { - return false; - } - return true; + return saleOrderDAO.countByExample(example) == 0; } public SaleOrder findById(Long id) { diff --git a/src/main/java/club/joylink/rtss/services/OrganizationService.java b/src/main/java/club/joylink/rtss/services/OrganizationService.java index d3566ded7..d333be13e 100644 --- a/src/main/java/club/joylink/rtss/services/OrganizationService.java +++ b/src/main/java/club/joylink/rtss/services/OrganizationService.java @@ -47,6 +47,8 @@ public class OrganizationService implements IOrganizationService { @Override public boolean isExist(Long id) { + if (id == null) + return false; if (organizationDAO.selectByPrimaryKey(id) == null) { return false; } diff --git a/src/main/java/club/joylink/rtss/services/PermissionService.java b/src/main/java/club/joylink/rtss/services/PermissionService.java index 248a4bb43..0e6897c3d 100644 --- a/src/main/java/club/joylink/rtss/services/PermissionService.java +++ b/src/main/java/club/joylink/rtss/services/PermissionService.java @@ -560,6 +560,7 @@ public class PermissionService implements IPermissionService { /** * 根据mapId获取该地图下的综合演练权限 */ + @Override public PermissionVO getJointSimulationPermissionByMapId(Long mapId) { PermissionExample example = new PermissionExample(); example.createCriteria() @@ -574,4 +575,19 @@ public class PermissionService implements IPermissionService { return new PermissionVO(permissions.get(0)); } + @Override + public Permission findJointSimulationEntity(Long mapId) { + PermissionExample example = new PermissionExample(); + example.createCriteria() + .andMapIdEqualTo(mapId) + .andNameLike(String.format("%%%s%%", "综合演练")); + example.or() + .andMapIdEqualTo(mapId) + .andNameLike(String.format("%%%s%%", "Comprehensive exercise cloud platform")); + List permissions = permissionDAO.selectByExample(example); + if (!CollectionUtils.isEmpty(permissions)) + return permissions.get(0); + return null; + } + } diff --git a/src/main/java/club/joylink/rtss/services/UserPermissionService.java b/src/main/java/club/joylink/rtss/services/UserPermissionService.java index 89f600715..cfa12be79 100644 --- a/src/main/java/club/joylink/rtss/services/UserPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/UserPermissionService.java @@ -244,22 +244,15 @@ public class UserPermissionService implements IUserPermissionService { /** * 获取指定类型的用户权限 - * - * @param userVO - * @param mapId - * @param prdType - * @param lessonId - * @param type - * @return */ - public List getGivenTypeUserPermissionVOList(UserVO userVO, Long mapId, String prdType, Long lessonId, String type) { + private List getGivenTypeUserPermissionVOList(UserVO userVO, Long mapId, String prdType, Long lessonId, String type) { PermissionVO permission; if (MapPrdTypeEnum.JOINT.getCode().equals(prdType)) { permission = iPermissionService.getJointSimulationPermissionByMapId(mapId); } else { permission = iPermissionService.getTeachPermissionByMapId(mapId); } - return this.getByUserIdAndPermissionId(userVO.getId(), permission.getId()); + return this.getValidByUserIdAndPermissionId(userVO.getId(), permission.getId()); // PermissionExample permissionExample = new PermissionExample(); @@ -290,9 +283,9 @@ public class UserPermissionService implements IUserPermissionService { } /** - * 根据用户id和权限id获取用户权限 + * 根据用户id和权限id获取有效的用户权限 */ - private List getByUserIdAndPermissionId(Long userId, Long permissionId) { + private List getValidByUserIdAndPermissionId(Long userId, Long permissionId) { UserPermissionExample example = new UserPermissionExample(); example.createCriteria() .andUserIdEqualTo(userId) diff --git a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java index b17343b77..71bf1455a 100644 --- a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java +++ b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.services.completition; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.constants.Project; import club.joylink.rtss.dao.CompetitionDAO; import club.joylink.rtss.dao.CompetitionRecordDAO; @@ -8,6 +9,10 @@ import club.joylink.rtss.entity.CompetitionExample; import club.joylink.rtss.entity.CompetitionRecord; import club.joylink.rtss.entity.CompetitionWithBLOBs; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.IGoodsService; +import club.joylink.rtss.services.IOrderService; +import club.joylink.rtss.services.IPermissionService; +import club.joylink.rtss.services.IUserPermissionService; import club.joylink.rtss.services.script.IScriptService; import club.joylink.rtss.services.script.IScriptSimulationService; import club.joylink.rtss.services.simulation.ProjectSimulationService; @@ -29,6 +34,7 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.competition.*; import club.joylink.rtss.vo.client.script.ScriptActionVO; import club.joylink.rtss.vo.client.script.ScriptVO; +import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; @@ -40,6 +46,7 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -74,6 +81,18 @@ public class CompetitionPracticalService implements ICompetitionPracticalService @Autowired private ATSMessageCollectAndDispatcher atsMessageCollectAndDispatcher; + @Autowired + private IUserPermissionService iUserPermissionService; + + @Autowired + private IPermissionService iPermissionService; + + @Autowired + private IGoodsService iGoodsService; + + @Autowired + private IOrderService iOrderService; + @Override public PageVO pagedQueryCompetition(CompetitionPagedQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); @@ -166,11 +185,19 @@ public class CompetitionPracticalService implements ICompetitionPracticalService @Override public void loadCompetition(String group, Long id, LoginUserInfoVO userInfo) { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); - Long scriptId = getEntity(id).getScriptId(); + CompetitionWithBLOBs competitionEntity = getEntity(id); + if (!competitionEntity.getName().startsWith("场景1")) { + Long mapId = simulation.getBuildParams().getMap().getId(); + List ups = iUserPermissionService.getSimulationUserPermission(userInfo.getUserVO(), + mapId, MapPrdTypeEnum.JOINT.getCode()); + BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertCollectionNotEmpty(ups, + "权限不足,无法使用场景"); + } + Long scriptId = competitionEntity.getScriptId(); iScriptSimulationService.loadScript(group, scriptId); ScriptBO script = simulation.getScript(); - CompetitionBO competition = this.getCompetitionBO(id, script); - simulation.setCompetition(competition); + CompetitionBO competitionBO = this.getCompetitionBO(id, script); + simulation.setCompetition(competitionBO); } @Override @@ -365,6 +392,34 @@ public class CompetitionPracticalService implements ICompetitionPracticalService competitionDAO.insert(competition); } + @Override + public UserPermissionVO queryPermissions(Long mapId, UserVO user) { + List permissions = iUserPermissionService.getSimulationUserPermission(user, mapId, MapPrdTypeEnum.JOINT.getCode()); + LocalDateTime now = LocalDateTime.now(); + Optional optional = permissions.stream() + .filter(up -> up.getRemains() > 0 && !up.getStartTime().isAfter(now) && (up.getEndTime() == null || !up.getEndTime().isBefore(now))) + .max((o1, o2) -> { + if (o1.getEndTime().isAfter(o2.getEndTime())) { + return 1; + } else if (o2.getEndTime().isAfter(o1.getEndTime())) { + return -1; + } else { + return 0; + } + }); + return optional.orElse(null); + } + + @Override + public String purchasePermission(Long mapId, Long amount, UserVO user) { +// PermissionVO jointPermission = iPermissionService.getJointSimulationPermissionByMapId(mapId); +// GoodsVO goods = iGoodsService.queryGoodsByPermissionId(jointPermission.getId()); +// OrderCreateVO orderCreateVO = new OrderCreateVO(); +// orderCreateVO.setOrganizationId(); +// iOrderService.createOrder() + return "待实现"; + } + /** * 保存结果 */ diff --git a/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java b/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java index 29a74d48a..e630007ad 100644 --- a/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java +++ b/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.completition; -import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.entity.CompetitionWithBLOBs; +import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; @@ -9,6 +9,7 @@ import club.joylink.rtss.vo.client.competition.CompetitionPagedQueryVO; import club.joylink.rtss.vo.client.competition.CompetitionResult; import club.joylink.rtss.vo.client.competition.CompetitionVO; import club.joylink.rtss.vo.client.competition.OperationStatisticVO; +import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; import java.util.List; @@ -107,4 +108,16 @@ public interface ICompetitionPracticalService { * @param competition */ void importFromJson(Long scriptId, String name, CompetitionWithBLOBs competition); + + /** + * 查询该地图下的综合演练权限 + * @return + */ + UserPermissionVO queryPermissions(Long mapId, UserVO user); + + /** + * 购买权限 + * @param amount 购买数量,单位为月 + */ + String purchasePermission(Long mapId, Long amount, UserVO user); } diff --git a/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java b/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java index 5f47edbc9..d4981daa2 100644 --- a/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java @@ -160,7 +160,7 @@ public class ClassStudentUserServiceImpl implements IClassStudentUserService { Permission permission = iPermissionService.findTeachPermissionEntity(gzbMapId); log.warn(String.format("项目[%s]没有有效的教学权限", projectCode)); if (permission == null) return; - GoodsVO good = iGoodsService.selectGoodsByPermissionId(permission.getId()); + GoodsVO good = iGoodsService.queryGoodsByPermissionId(permission.getId()); List userIds = oldSysUsers.stream().map(SysUser::getId).collect(Collectors.toList()); List userPermissions = iUserPermissionService.findEntity(userIds, true); List usersWithPermissions = userPermissions.stream() From 0a53d304aa322ce03a0826bd9ceb877397272a09 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 31 Dec 2020 09:53:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0ISCS=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/ReleaseService.java | 31 ++++++++++++++++--- .../rtss/vo/client/ReleaseConfigVO.java | 17 +++++----- .../joylink/rtss/vo/client/ReleaseVO.java | 2 ++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/ReleaseService.java b/src/main/java/club/joylink/rtss/services/ReleaseService.java index 6a6c72139..78307f6ff 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseService.java @@ -64,6 +64,9 @@ public class ReleaseService implements IReleaseService { @Autowired private CompetitionDAO competitionDAO; + @Autowired + private IscsDAO iscsDAO; + @Override public ReleaseVO exportAsJson(Long mapId, ReleaseConfigVO config) { ReleaseVO releaseVO = new ReleaseVO(); @@ -78,7 +81,7 @@ public class ReleaseService implements IReleaseService { RealLine realLine = realLines.get(0); releaseVO.setRealLineConfig(realLine); - if (config.getRunPlan()) { + if (config.isRunPlan()) { this.confirmRunPlanExist(mapId); RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample(); runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId); @@ -107,7 +110,7 @@ public class ReleaseService implements IReleaseService { } } } - if (config.getMap3dData()) { + if (config.isMap3dData()) { Map3dDataExample map3dDataExample = new Map3dDataExample(); map3dDataExample.createCriteria().andMapIdEqualTo(mapId); List map3dDataWithBLOBs = map3dDataDAO.selectByExampleWithBLOBs(map3dDataExample); @@ -115,7 +118,7 @@ public class ReleaseService implements IReleaseService { releaseVO.setMap3dData(map3dDataWithBLOBs.get(0)); } } - if (config.getCommandDefinition()) { + if (config.isCommandDefinition()) { MapVO mapInfo2 = iMapService.getMapInfoById(mapId); CommandDefinitionExample commandDefinitionExample = new CommandDefinitionExample(); commandDefinitionExample.createCriteria().andLineCodeEqualTo(mapInfo2.getLineCode()); @@ -124,7 +127,7 @@ public class ReleaseService implements IReleaseService { releaseVO.setCommandDefinitionList(commandDefinitions); } } - if (config.getIbp()) { + if (config.isIbp()) { IbpExample example = new IbpExample(); example.createCriteria().andMapIdEqualTo(mapId); List ibps = ibpDAO.selectByExampleWithBLOBs(example); @@ -132,7 +135,15 @@ public class ReleaseService implements IReleaseService { releaseVO.setIbpList(ibps); } } - if (config.getScript()) { + if (config.isIscs()) { + IscsExample example = new IscsExample(); + example.createCriteria().andMapIdEqualTo(mapId); + List iscsList = iscsDAO.selectByExampleWithBLOBs(example); + if (!CollectionUtils.isEmpty(iscsList)) { + releaseVO.setIscsList(iscsList); + } + } + if (config.isScript()) { //草稿地图 ScriptDraftExample example = new ScriptDraftExample(); example.createCriteria().andMapIdEqualTo(mapId); @@ -283,6 +294,16 @@ public class ReleaseService implements IReleaseService { } ibpDAO.batchInsertWithId(ibpList); } + if (!CollectionUtils.isEmpty(releaseVO.getIscsList())) { + List iscsList = releaseVO.getIscsList(); + //删除旧数据 + IscsExample example = new IscsExample(); + example.createCriteria().andMapIdEqualTo(mapId); + iscsDAO.deleteByExample(example); + //插入新数据 + iscsList.forEach(iscs->iscs.setMapId(mapId)); + iscsDAO.batchInsert(iscsList); + } if (!CollectionUtils.isEmpty(releaseVO.getScriptDrafts())) { //删除旧草稿 ScriptDraftExample example = new ScriptDraftExample(); diff --git a/src/main/java/club/joylink/rtss/vo/client/ReleaseConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/ReleaseConfigVO.java index c47436962..c53ac99e0 100644 --- a/src/main/java/club/joylink/rtss/vo/client/ReleaseConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/ReleaseConfigVO.java @@ -12,23 +12,26 @@ import javax.validation.constraints.NotNull; public class ReleaseConfigVO { @NotNull - private Boolean mapData; + private boolean mapData; @NotNull - private Boolean runPlan; + private boolean runPlan; @NotNull - private Boolean map3dData; + private boolean map3dData; @NotNull - private Boolean commandDefinition; + private boolean commandDefinition; @NotNull - private Boolean realLineConfig; + private boolean realLineConfig; @NotNull - private Boolean ibp; + private boolean ibp; @NotNull - private Boolean script; + private boolean iscs; + + @NotNull + private boolean script; } diff --git a/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java b/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java index 80ff12f65..75d725c00 100644 --- a/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java @@ -52,6 +52,8 @@ public class ReleaseVO { */ private List ibpList; + private List iscsList; + private List scriptDrafts; private List scripts; From 55e273163425622d706392c70a32cdd05013d571 Mon Sep 17 00:00:00 2001 From: DU Date: Thu, 31 Dec 2020 13:44:59 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/ExamService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index e0bfb4de6..43196e86d 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -297,7 +297,7 @@ public class ExamService implements IExamService{ while (iterator.hasNext()) { ExamDefinition exam = iterator.next(); if (null != exam.getEndTime() && now.isAfter(exam.getEndTime())) { - this.offLine(exam.getId(), null); + this.offLine(exam.getId(), userVO); iterator.remove(); } else if (Objects.nonNull(examIds) && !examIds.contains(exam.getId())) { iterator.remove(); From 32bb3e691edb36b8f7c2af5a9530cf83a7d07682 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 31 Dec 2020 16:30:02 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=88=A4=E6=96=ADbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/simulation/cbtc/data/map/Station.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index 3346007e4..b03f5b972 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -398,6 +398,9 @@ public class Station extends MayOutOfOrderDevice { * 是否处于中控下 */ public boolean underCenterControl() { + if (isCentralized()) { + return isCenterControl(); + } if (hasControlMode) { return isCenterControl(); } else { @@ -409,6 +412,8 @@ public class Station extends MayOutOfOrderDevice { * 是否处于站控下 */ public boolean underStandControl() { + if (isCentralized()) + return isStandControl(); if (hasControlMode) { return isStandControl(); } else { From 2434905228ba789c02a97495fbab876619ff16cd Mon Sep 17 00:00:00 2001 From: DU Date: Thu, 31 Dec 2020 18:01:09 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=80=82=E9=85=8D?= =?UTF-8?q?=E6=96=B0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/training/constant/TrainingConsts.java | 4 +++- .../rtss/services/training/generatornew/GeneratorNew.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java b/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java index 531a37cf4..9111c33fe 100644 --- a/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java +++ b/src/main/java/club/joylink/rtss/services/training/constant/TrainingConsts.java @@ -42,7 +42,9 @@ public interface TrainingConsts { /** 始端信号机 */ START_SIGNAL, /** 终端信号机 */ - END_SIGNAL + END_SIGNAL, + /** 终端按钮信号机 */ + END_BUTTON_SIGNAL } } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java index 283ba64e4..6aa2251fd 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java @@ -77,6 +77,9 @@ public interface GeneratorNew { case END_SIGNAL: s.setDeviceCode(((Route) mapDevice).getDestination().getCode()); break; + case END_BUTTON_SIGNAL: + s.setDeviceCode(((Route) mapDevice).getDestinationButtonSignal().getCode()); + break; default: s.setDeviceCode(mapDevice.getCode()); }