This commit is contained in:
DU 2020-12-14 17:10:12 +08:00
commit 565c5ee466
10 changed files with 85 additions and 68 deletions

View File

@ -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 '用户角色';

View File

@ -6,7 +6,7 @@ package club.joylink.rtss.constants;
public enum Project {
/** 自己项目 */
DEFAULT,
/** 西铁院定制项目 */
/** 西铁院项目 */
XTY,
/** 南铁院项目 */
NTY,

View File

@ -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);
}
}

View File

@ -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<OrderDetailVO> findOrderDetailVOListByOrderId(Long id);
/**
* 创建 内部分配订单创建对象
*/
OrderCreateVO createInternalOrderCreateVO(Long organizationId, List<OrderDetailCreateVO> orderDetails);
}

View File

@ -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<DistributeVO> queryPersonalDistributeList(UserVO user);
List<UserPermissionVO> queryUserPermissionsOfDistribute(Long distributeId);
void handleOldDataColumnPackage();
String transferPermission(DistributeSelectVO distributeSelectVO, UserVO user);
String distributePermission(DistributeSelectVO distributeSelectVO, UserVO user);
DistributeVO findById(Long id);
List<DistributeVO> getByParentId(Long distributeId);
@ -102,4 +94,9 @@ public interface IPermissionDistributeService {
* @return
*/
DistributeVO generateGiftDistribute(PermissionGenerateConfigVO configVO);
/**
* 创建项目下所有地图的权限分发
*/
String createAllMapDistribute(Project project, Integer num, UserVO user);
}

View File

@ -56,4 +56,10 @@ public interface IPermissionService {
Permission findTeachPermissionEntity(Long mapId);
List<PermissionVO> getByMapId(Long mapId);
/**
* 获取综合演练和教学的权限
* @return
*/
List<Permission> getJointAndTeachEntities(List<Long> mapIds);
}

View File

@ -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<SaleOrderDetail> orderDetailList = saleOrderDetailDAO.selectByExample(example);
return orderDetailList.stream().map(saleOrderDetail -> new OrderDetailVO(saleOrderDetail)).collect(Collectors.toList());
}
@Override
public OrderCreateVO createInternalOrderCreateVO(Long organizationId, List<OrderDetailCreateVO> 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;
}
}

View File

@ -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<UserPermissionVO> queryUserPermissionsOfDistribute(Long distributeId) {
List<UserPermissionVO> voList = new ArrayList<>();
PermissionDistribute distribute = this.getEntityById(distributeId);
if (distribute.getIsPackage()) {
List<PermissionDistribute> 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<PermissionDistribute> 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<MapVO> maps = iMapService.queryOnlineMapInfoListOfProject(project);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(maps,
String.format("项目[%s]下没有地图", project));
List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList());
List<Permission> permissions = iPermissionService.getJointAndTeachEntities(mapIds);
List<GoodsVO> goodsList = iGoodsService.getByPermissionIds(permissions.stream().map(Permission::getId).collect(Collectors.toList()));
List<OrderDetailCreateVO> 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);

View File

@ -541,6 +541,25 @@ public class PermissionService implements IPermissionService {
return permissions;
}
@Override
public List<Permission> getJointAndTeachEntities(List<Long> 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<Permission> permissions = permissionDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions,
"权限数据不存在");
return permissions;
}
/**
* 根据mapId获取该地图下的综合演练权限
*/

View File

@ -62,7 +62,8 @@ public class Joylink3DMessageService {
public void tdtStatusCollectAndSend(Simulation simulation) {
List<TdtStatusVO> list = new ArrayList<>();
SimulationDataRepository repository = simulation.getRepository();
for (Stand stand : repository.getStandList()) {
List<Stand> 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);