From 9cfab25c4d38462ecbc10b38b435bd089a106f8f Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Mon, 14 Dec 2020 14:41:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9TDT=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E9=87=87=E9=9B=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/constants/Project.java | 2 +- .../cbtc/communication/Joylink3DMessageService.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/constants/Project.java b/src/main/java/club/joylink/rtss/constants/Project.java index 8b5ddd977..64758a342 100644 --- a/src/main/java/club/joylink/rtss/constants/Project.java +++ b/src/main/java/club/joylink/rtss/constants/Project.java @@ -6,7 +6,7 @@ package club.joylink.rtss.constants; public enum Project { /** 自己项目 */ DEFAULT, - /** 西铁院定制项目 */ + /** 西铁院项目 */ XTY, /** 南铁院项目 */ NTY, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java index 2f2f039e5..568b50ade 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java @@ -62,7 +62,8 @@ public class Joylink3DMessageService { public void tdtStatusCollectAndSend(Simulation simulation) { List list = new ArrayList<>(); SimulationDataRepository repository = simulation.getRepository(); - for (Stand stand : repository.getStandList()) { + List standList = repository.getStandList(); + for (Stand stand : standList) { if (!stand.isSmall()) { TdtStatusVO statusVO = repository.queryTdtStatus(stand.getCode()); if (Objects.isNull(statusVO)) { @@ -74,8 +75,6 @@ public class Joylink3DMessageService { list.add(statusVO); } } - TdtStatusVO tdtStatusVO = new TdtStatusVO(stand); - list.add(tdtStatusVO); } } SocketMessageVO message = SocketMessageFactory.buildTrainIsAbout2ArriveMessage(simulation.getGroup(), list); From 98ec6a2453847f721e781fc9b77942000471cbfb Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 14 Dec 2020 16:28:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0<=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E4=B8=8B=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E7=9A=84=E6=9D=83=E9=99=90=E5=88=86=E5=8F=91?= =?UTF-8?q?>=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20201208.sql | 2 +- .../PermissionDistributeController.java | 29 +++------- .../joylink/rtss/services/IOrderService.java | 6 +++ .../IPermissionDistributeService.java | 15 +++--- .../rtss/services/IPermissionService.java | 6 +++ .../joylink/rtss/services/OrderService.java | 16 ++++++ .../services/PermissionDistributeService.java | 53 +++++++------------ .../rtss/services/PermissionService.java | 19 +++++++ 8 files changed, 82 insertions(+), 64 deletions(-) diff --git a/sql/20201208.sql b/sql/20201208.sql index cc4f8c4f5..7afd45450 100644 --- a/sql/20201208.sql +++ b/sql/20201208.sql @@ -1,2 +1,2 @@ -alter table user_simulation_stats modify role varchar(32) null comment '用户角色'; +alter table user_simulation_stats modify role varchar(64) null comment '用户角色'; diff --git a/src/main/java/club/joylink/rtss/controller/permission/PermissionDistributeController.java b/src/main/java/club/joylink/rtss/controller/permission/PermissionDistributeController.java index e87b6980c..53b11aa3e 100644 --- a/src/main/java/club/joylink/rtss/controller/permission/PermissionDistributeController.java +++ b/src/main/java/club/joylink/rtss/controller/permission/PermissionDistributeController.java @@ -1,10 +1,12 @@ package club.joylink.rtss.controller.permission; +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.constants.RoleEnum; +import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.services.IPermissionDistributeService; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.order.OrderCreateVO; -import club.joylink.rtss.vo.client.permission.DistributeSelectVO; import club.joylink.rtss.vo.client.permissionDistribute.DistributeVO; import club.joylink.rtss.vo.client.permissionDistribute.PermissionDistributeQueryVO; import club.joylink.rtss.vo.client.userPermission.UserPermissionDistributeVO; @@ -99,26 +101,11 @@ public class PermissionDistributeController { return permissionDistributeService.queryPackageDetail(id, queryVO); } - - /*------------------未实现接口-------------------*/ - @ApiOperation(value = "权限分发") - @PostMapping(path="/distribute") - public String distributePermission(@RequestBody @Validated DistributeSelectVO distributeSelectVO, - @RequestAttribute @ApiIgnore UserVO user) { - return permissionDistributeService.distributePermission(distributeSelectVO, user); - } - - @ApiOperation(value = "权限转赠") - @PostMapping(path="/transfer") - public String transferPermission(@RequestBody @Validated DistributeSelectVO distributeSelectVO, - @RequestAttribute @ApiIgnore UserVO user) { - return permissionDistributeService.transferPermission(distributeSelectVO, user); - } - - @ApiOperation(value = "处理旧数据是否包") - @PutMapping(path = "/package") - public void handleOldDataColumnPackage() { - this.permissionDistributeService.handleOldDataColumnPackage(); + @Role({RoleEnum.SuperAdmin, RoleEnum.Admin}) + @ApiOperation("创建项目下所有地图权限的权限分发") + @PostMapping("/{project}/allMap/distribute") + public String createAllMapDistribute(@PathVariable Project project, Integer num, @RequestAttribute UserVO user) { + return permissionDistributeService.createAllMapDistribute(project, num, user); } } diff --git a/src/main/java/club/joylink/rtss/services/IOrderService.java b/src/main/java/club/joylink/rtss/services/IOrderService.java index ba1cdf399..ea1252504 100644 --- a/src/main/java/club/joylink/rtss/services/IOrderService.java +++ b/src/main/java/club/joylink/rtss/services/IOrderService.java @@ -3,6 +3,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.order.OrderCreateVO; +import club.joylink.rtss.vo.client.order.OrderDetailCreateVO; import club.joylink.rtss.vo.client.order.OrderDetailVO; import club.joylink.rtss.vo.client.order.OrderVO; import club.joylink.rtss.vo.client.permission.OrderQueryVO; @@ -50,4 +51,9 @@ public interface IOrderService { OrderVO findByCode(String orderCode); List findOrderDetailVOListByOrderId(Long id); + + /** + * 创建 内部分配订单创建对象 + */ + OrderCreateVO createInternalOrderCreateVO(Long organizationId, List orderDetails); } diff --git a/src/main/java/club/joylink/rtss/services/IPermissionDistributeService.java b/src/main/java/club/joylink/rtss/services/IPermissionDistributeService.java index e8ca05967..40432c806 100644 --- a/src/main/java/club/joylink/rtss/services/IPermissionDistributeService.java +++ b/src/main/java/club/joylink/rtss/services/IPermissionDistributeService.java @@ -1,9 +1,9 @@ package club.joylink.rtss.services; +import club.joylink.rtss.constants.Project; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.order.OrderCreateVO; -import club.joylink.rtss.vo.client.permission.DistributeSelectVO; import club.joylink.rtss.vo.client.permissionDistribute.DistributeVO; import club.joylink.rtss.vo.client.permissionDistribute.PermissionDistributeQueryVO; import club.joylink.rtss.vo.client.userPermission.UserPermissionDistributeVO; @@ -63,14 +63,6 @@ public interface IPermissionDistributeService { List queryPersonalDistributeList(UserVO user); - List queryUserPermissionsOfDistribute(Long distributeId); - - void handleOldDataColumnPackage(); - - String transferPermission(DistributeSelectVO distributeSelectVO, UserVO user); - - String distributePermission(DistributeSelectVO distributeSelectVO, UserVO user); - DistributeVO findById(Long id); List getByParentId(Long distributeId); @@ -102,4 +94,9 @@ public interface IPermissionDistributeService { * @return */ DistributeVO generateGiftDistribute(PermissionGenerateConfigVO configVO); + + /** + * 创建项目下所有地图的权限分发 + */ + String createAllMapDistribute(Project project, Integer num, UserVO user); } diff --git a/src/main/java/club/joylink/rtss/services/IPermissionService.java b/src/main/java/club/joylink/rtss/services/IPermissionService.java index ad0aeb4ce..f2d80d8e6 100644 --- a/src/main/java/club/joylink/rtss/services/IPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/IPermissionService.java @@ -56,4 +56,10 @@ public interface IPermissionService { Permission findTeachPermissionEntity(Long mapId); List getByMapId(Long mapId); + + /** + * 获取综合演练和教学的权限 + * @return + */ + List getJointAndTeachEntities(List mapIds); } diff --git a/src/main/java/club/joylink/rtss/services/OrderService.java b/src/main/java/club/joylink/rtss/services/OrderService.java index 058951c9f..6a8fcd29a 100644 --- a/src/main/java/club/joylink/rtss/services/OrderService.java +++ b/src/main/java/club/joylink/rtss/services/OrderService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.constants.SaleOrderPayStatusEnum; import club.joylink.rtss.constants.SaleOrderTypeEnum; import club.joylink.rtss.dao.SaleOrderDAO; import club.joylink.rtss.dao.SaleOrderDetailDAO; @@ -271,4 +272,19 @@ public class OrderService implements IOrderService { List orderDetailList = saleOrderDetailDAO.selectByExample(example); return orderDetailList.stream().map(saleOrderDetail -> new OrderDetailVO(saleOrderDetail)).collect(Collectors.toList()); } + + @Override + public OrderCreateVO createInternalOrderCreateVO(Long organizationId, List orderDetails) { + if (organizationId == null) { + organizationId = iOrganizationService.queryOrganization().get(0).getId(); + } + OrderCreateVO orderCreate = new OrderCreateVO(); + orderCreate.setOrganizationId(organizationId); + orderCreate.setOrderType(SaleOrderTypeEnum.Internal_Distribution.getCode()); + orderCreate.setForever(true); + orderCreate.setStartTime(LocalDateTime.now()); + orderCreate.setPayStatus(SaleOrderPayStatusEnum.No_Need.getCode()); + orderCreate.setDetailCreateVOList(orderDetails); + return orderCreate; + } } diff --git a/src/main/java/club/joylink/rtss/services/PermissionDistributeService.java b/src/main/java/club/joylink/rtss/services/PermissionDistributeService.java index 5fecb3a3c..4d7195216 100644 --- a/src/main/java/club/joylink/rtss/services/PermissionDistributeService.java +++ b/src/main/java/club/joylink/rtss/services/PermissionDistributeService.java @@ -3,6 +3,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.configuration.configProp.OtherConfig; import club.joylink.rtss.configuration.configProp.WeChatConfig; import club.joylink.rtss.constants.PermissionDistributeSourceEnum; +import club.joylink.rtss.constants.Project; import club.joylink.rtss.constants.StatusEnum; import club.joylink.rtss.constants.SystemEnv; import club.joylink.rtss.dao.PermissionDistributeDAO; @@ -12,10 +13,12 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.auth.IAuthenticateService; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.goods.GoodsVO; +import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.order.OrderCreateVO; +import club.joylink.rtss.vo.client.order.OrderDetailCreateVO; import club.joylink.rtss.vo.client.order.OrderDetailVO; import club.joylink.rtss.vo.client.order.OrderVO; -import club.joylink.rtss.vo.client.permission.DistributeSelectVO; import club.joylink.rtss.vo.client.permission.PermissionVO; import club.joylink.rtss.vo.client.permissionDistribute.DistributeVO; import club.joylink.rtss.vo.client.permissionDistribute.PermissionDistributeQueryVO; @@ -519,7 +522,7 @@ public class PermissionDistributeService implements IPermissionDistributeService .andDistributeIdEqualTo(relDistribute.getId()) .andStatusEqualTo(StatusEnum.Valid.getCode()); BusinessExceptionAssertEnum.OPERATION_REPEAT.assertTrue( - userPermissionDAO.countByExample(example)==0, + userPermissionDAO.countByExample(example) == 0, "已经领取过,不能重复领取"); } } else { @@ -529,7 +532,7 @@ public class PermissionDistributeService implements IPermissionDistributeService .andDistributeIdEqualTo(distribute.getId()) .andStatusEqualTo(StatusEnum.Valid.getCode()); BusinessExceptionAssertEnum.OPERATION_REPEAT.assertTrue( - userPermissionDAO.countByExample(example)==0, + userPermissionDAO.countByExample(example) == 0, "已经领取过,不能重复领取"); } } @@ -571,21 +574,6 @@ public class PermissionDistributeService implements IPermissionDistributeService return voList; } - @Override - public List queryUserPermissionsOfDistribute(Long distributeId) { - List voList = new ArrayList<>(); - PermissionDistribute distribute = this.getEntityById(distributeId); - if (distribute.getIsPackage()) { - List distributeList = this.getEntityByParentId(distributeId); - distributeList.forEach(sub -> { - voList.addAll(this.iUserPermissionService.queryByDistribute(sub.getId())); - }); - } else { - voList.addAll(this.iUserPermissionService.queryByDistribute(distributeId)); - } - return voList; - } - private List getEntityByParentId(Long parentId) { PermissionDistributeExample example = new PermissionDistributeExample(); example.createCriteria().andParentIdEqualTo(parentId); @@ -595,21 +583,6 @@ public class PermissionDistributeService implements IPermissionDistributeService return distributeList; } - @Override - public void handleOldDataColumnPackage() { - - } - - @Override - public String transferPermission(DistributeSelectVO distributeSelectVO, UserVO user) { - return null; - } - - @Override - public String distributePermission(DistributeSelectVO distributeSelectVO, UserVO user) { - return null; - } - public DistributeVO findById(Long id) { PermissionDistribute distribute = permissionDistributeDAO.selectByPrimaryKey(id); if (distribute == null) { @@ -687,6 +660,20 @@ public class PermissionDistributeService implements IPermissionDistributeService return new DistributeVO(distribute); } + @Override + public String createAllMapDistribute(Project project, Integer num, UserVO user) { + iSysUserService.ensureAdmin(user); + List maps = iMapService.queryOnlineMapInfoListOfProject(project); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(maps, + String.format("项目[%s]下没有地图", project)); + List mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList()); + List permissions = iPermissionService.getJointAndTeachEntities(mapIds); + List goodsList = iGoodsService.getByPermissionIds(permissions.stream().map(Permission::getId).collect(Collectors.toList())); + List orderDetails = goodsList.stream().map(goodsVO -> new OrderDetailCreateVO(goodsVO.getId(), num)).collect(Collectors.toList()); + OrderCreateVO orderCreateVO = iOrderService.createInternalOrderCreateVO(null, orderDetails); + return createQuickly(orderCreateVO, user); + } + @Override public void recoveryAfterRestoreUserPermission(Long id, Integer amount) { PermissionDistribute distribute = getEntityById(id); diff --git a/src/main/java/club/joylink/rtss/services/PermissionService.java b/src/main/java/club/joylink/rtss/services/PermissionService.java index 4e2df8b89..e628ad7ee 100644 --- a/src/main/java/club/joylink/rtss/services/PermissionService.java +++ b/src/main/java/club/joylink/rtss/services/PermissionService.java @@ -541,6 +541,25 @@ public class PermissionService implements IPermissionService { return permissions; } + @Override + public List getJointAndTeachEntities(List mapIds) { + PermissionExample example = new PermissionExample(); + example.createCriteria() + .andMapIdIn(mapIds) + .andTypeEqualTo(PermissionTypeEnum.Teaching_Package.getCode()) + .andIsPackageEqualTo(true); + example.or() + .andMapIdIn(mapIds) + .andNameLike(String.format("%%%s%%", "综合演练")); + example.or() + .andMapIdIn(mapIds) + .andNameLike(String.format("%%%s%%", "Comprehensive exercise cloud platform")); + List permissions = permissionDAO.selectByExample(example); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions, + "权限数据不存在"); + return permissions; + } + /** * 根据mapId获取该地图下的综合演练权限 */