From 21406a1726b2bd1259694be5d8648b923b727f21 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 30 Dec 2020 14:37:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/IVoiceService.java | 29 +------------------ .../joylink/rtss/vo/client/LoginStatusVO.java | 5 ++-- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/IVoiceService.java b/src/main/java/club/joylink/rtss/services/IVoiceService.java index c281ee5c6..2c6f27cd4 100644 --- a/src/main/java/club/joylink/rtss/services/IVoiceService.java +++ b/src/main/java/club/joylink/rtss/services/IVoiceService.java @@ -58,7 +58,7 @@ public interface IVoiceService { } saveFile = new File(localFilePath); //上传文件 - String url = "https://joylink.club/jlfile/api/upload/AUDIO?appId=00001&appSecret=joylink00001"; + String url = "https://upload.joylink.club/api/upload/AUDIO?appId=00001&appSecret=joylink00001"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); MultiValueMap map = new LinkedMultiValueMap<>(); @@ -85,33 +85,6 @@ public interface IVoiceService { } } - static VoiceFile saveFile(MultipartFile multipartFile) { - RestTemplate restTemplate = new RestTemplate(); - String url = "https://joylink.club/jlfile/api/upload/AUDIO?appId=00001&appSecret=joylink00001"; - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.MULTIPART_FORM_DATA); - File tempFile = null; - try { - tempFile = File.createTempFile("fileName", ".wav"); - multipartFile.transferTo(tempFile); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("file", new FileSystemResource(tempFile)); - - ResponseEntity responseEntity = restTemplate.postForEntity(url, map, String.class); - String body = responseEntity.getBody(); -// body = body.replaceAll("\\\\", "/"); - CommonJsonResponse response = JsonUtils.read(body, CommonJsonResponse.class); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertEquals(200, response.getCode()); - String path = (String) response.getData(); - return new VoiceFile(path, null); - } catch (Exception e) { - throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e); - } finally { - if (tempFile != null) - tempFile.delete(); - } - } - static String handleAndSaveFile(MultipartFile file) throws IOException { String contentType = file.getContentType(); BusinessExceptionAssertEnum.UNSUPPORTED_FILE_FORMAT.assertTrue( diff --git a/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java b/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java index 5c4e6f393..623163d34 100644 --- a/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java @@ -1,9 +1,9 @@ package club.joylink.rtss.vo.client; -import com.fasterxml.jackson.annotation.JsonIgnore; import club.joylink.rtss.constants.Client; import club.joylink.rtss.constants.Project; import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Builder; import lombok.Getter; import lombok.Setter; @@ -59,8 +59,7 @@ public class LoginStatusVO { // 项目设备,永不过期 return; } -// if (LocalDateTime.now().isAfter(time.plusSeconds(3))) { - if (LocalDateTime.now().isAfter(time.plusMinutes(2))) { + if (LocalDateTime.now().isAfter(time.plusMinutes(5))) { this.status = ScanLoginStatus.EXPIRE; } } 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 2/3] =?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 3/3] =?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;