轨道交通项目迁出问题修改4(可以启动了)

This commit is contained in:
walker-sheng 2020-11-19 18:12:24 +08:00
parent 413a2c2b94
commit 1073fc66b6
11 changed files with 76 additions and 463 deletions

View File

@ -1,11 +1,13 @@
package club.joylink.rtss;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@MapperScan(basePackages= {"club.joylink.rtss.dao"})
public class RtssApplication {
public static void main(String[] args) {

View File

@ -29,13 +29,16 @@ public enum BusinessExceptionAssertEnum implements BusinessExceptionAssert {
SIMULATION_PERMISSION_NOT_EXIST(10013, "simulation permission not exist"),
SIMULATION_PERMISSION_NOT_AVAILABLE(10014, "simulation permission not available"),
UNSUPPORTED_FILE_FORMAT(10015, "unsupported file format"),
OPERATION_REPEAT(10016, "operation repeat"),
DATA_ERROR(11000, "data error"),
CI_GENERATE_ERROR(11001, "ci data generate error"),
MAP_PASSENGER_FLOW_DATA_ERROR(11002, "map passenger flow data error"),
DATA_UNIQUE_PROPERTY_REPEAT(10013, "data unique property repeat"),
DATA_INVALID(11004, "data invalid"),
DATA_BEEN_USED(11005, "data has been used"),
DATA_STATE_INCORRECT(11007, "data state incorrect"),
// 运行图工具
BEYOND_RECEPTION(101, "beyond station reception"),

View File

@ -1,8 +1,5 @@
package club.joylink.rtss.services;
import club.joylink.rtss.services.auth.IAuthenticateService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import club.joylink.rtss.configuration.configProp.OtherConfig;
import club.joylink.rtss.configuration.configProp.WeChatConfig;
import club.joylink.rtss.constants.PermissionDistributeSourceEnum;
@ -11,6 +8,8 @@ import club.joylink.rtss.constants.SystemEnv;
import club.joylink.rtss.dao.PermissionDistributeDAO;
import club.joylink.rtss.dao.UserPermissionDAO;
import club.joylink.rtss.entity.*;
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.order.OrderCreateVO;
@ -25,12 +24,14 @@ import club.joylink.rtss.vo.client.userPermission.UserPermissionDistributeVO;
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
import club.joylink.rtss.vo.client.validGroup.ValidList;
import club.joylink.rtss.vo.user.PermissionGenerateConfigVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -176,9 +177,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
public String distributeFromOrder(String orderCode, UserVO user) {
//校验
OrderVO order = iOrderService.findByCode(orderCode);
if (order == null) {
throw new BusinessException(ExceptionMapping.ORDER_NOT_EXIST);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(order);
Long permissionDistributeId;
if (order.getQrCodeGenerated()) {
@ -372,9 +371,8 @@ public class PermissionDistributeService implements IPermissionDistributeService
private PermissionDistribute getEntityById(Long id) {
PermissionDistribute distribute = permissionDistributeDAO.selectByPrimaryKey(id);
if (distribute == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST, String.format("id为[%s]的权限分发不存在", id));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
String.format("id为[%s]的权限分发不存在", id));
return distribute;
}
@ -386,12 +384,10 @@ public class PermissionDistributeService implements IPermissionDistributeService
public void restoreDistributeToUserPermission(Long id) {
//校验
PermissionDistribute distribute = getEntityById(id);
if (StatusEnum.Invalid.getCode().equals(distribute.getStatus())) {
throw new BusinessException(ExceptionMapping.ILLEGAL_OPERATION, "该权限分发已失效");
}
if (!PermissionDistributeSourceEnum.FromUser.getCode().equals(distribute.getSource())) {
throw new BusinessException(ExceptionMapping.ILLEGAL_OPERATION, "从用户权限创建的权限分发才可以回收");
}
BusinessExceptionAssertEnum.DATA_INVALID.assertNotEquals(StatusEnum.Invalid.getCode(), distribute.getStatus(),
"该权限分发已失效");
BusinessExceptionAssertEnum.DATA_STATE_INCORRECT.assertEquals(PermissionDistributeSourceEnum.FromUser.getCode(),
distribute.getSource(), "从用户权限创建的权限分发才可以回收");
//先让这个权限分发本身失效
distribute.setStatus(StatusEnum.Invalid.getCode());
@ -453,9 +449,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
@Override
public DistributeVO getById(Long id) {
PermissionDistribute distribute = permissionDistributeDAO.selectByPrimaryKey(id);
if (distribute == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute);
return new DistributeVO(distribute);
}
@ -509,13 +503,12 @@ public class PermissionDistributeService implements IPermissionDistributeService
*/
private void canReceiveValid(PermissionDistribute distribute, UserVO userVO) {
//如果权限分发失效
if (distribute.getStatus().equals(StatusEnum.Invalid.getCode())) {
throw new BusinessException(ExceptionMapping.PERMISSION_DISTRIBUTE_EXPIRE, "权限分发已经失效");
}
BusinessExceptionAssertEnum.DATA_INVALID.assertNotEquals(StatusEnum.Invalid.getCode(), distribute.getStatus(),
"权限分发已经失效");
//如果权限已被领取完
if (distribute.getRemains() <= 0) {
throw new BusinessException(ExceptionMapping.PERMISSION_DISTRIBUTE_FINISHED, "权限分发已被领取完");
}
BusinessExceptionAssertEnum.DATA_STATE_INCORRECT.assertTrue(distribute.getRemains() > 0,
"权限分发已被领取完");
//如果该用户已经领取过
if (distribute.getIsPackage()) {
List<PermissionDistribute> relDistributeList = getEntityByParentId(distribute.getId());
@ -525,9 +518,9 @@ public class PermissionDistributeService implements IPermissionDistributeService
.andUserIdEqualTo(userVO.getId())
.andDistributeIdEqualTo(relDistribute.getId())
.andStatusEqualTo(StatusEnum.Valid.getCode());
if (userPermissionDAO.countByExample(example) != 0) {
throw new BusinessException(ExceptionMapping.PERMISSION_DISTRIBUTE_ALREADY_GET, "已经领取过,不能重复领取");
}
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertTrue(
userPermissionDAO.countByExample(example)==0,
"已经领取过,不能重复领取");
}
} else {
UserPermissionExample example = new UserPermissionExample();
@ -535,10 +528,9 @@ public class PermissionDistributeService implements IPermissionDistributeService
.andUserIdEqualTo(userVO.getId())
.andDistributeIdEqualTo(distribute.getId())
.andStatusEqualTo(StatusEnum.Valid.getCode());
if (userPermissionDAO.countByExample(example) != 0) {
throw new BusinessException(ExceptionMapping.PERMISSION_DISTRIBUTE_ALREADY_GET, "已经领取过,不能重复领取");
}
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertTrue(
userPermissionDAO.countByExample(example)==0,
"已经领取过,不能重复领取");
}
}
@ -598,9 +590,8 @@ public class PermissionDistributeService implements IPermissionDistributeService
PermissionDistributeExample example = new PermissionDistributeExample();
example.createCriteria().andParentIdEqualTo(parentId);
List<PermissionDistribute> distributeList = permissionDistributeDAO.selectByExample(example);
if (CollectionUtils.isEmpty(distributeList)) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST, String.format("parentId为[%s]的权限分发不存在", parentId));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(distributeList,
String.format("parentId为[%s]的权限分发不存在", parentId));
return distributeList;
}
@ -644,9 +635,8 @@ public class PermissionDistributeService implements IPermissionDistributeService
public List<DistributeVO> getByFromUserPermissionId(Long userPermissionId) {
List<DistributeVO> voList = findByFromUserPermissionId(userPermissionId);
if (CollectionUtils.isEmpty(voList)) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST, String.format("没有从id为[%s]的用户权限创建的权限分发", userPermissionId));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(voList,
String.format("没有从id为[%s]的用户权限创建的权限分发", userPermissionId));
return voList;
}
@ -722,9 +712,8 @@ public class PermissionDistributeService implements IPermissionDistributeService
@Override
public DistributeVO getByOrderCode(String orderCode) {
PermissionDistribute distribute = findByOrderCode(orderCode);
if (distribute == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST, String.format("订单编号为[%s]的权限分发不存在", orderCode));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
String.format("订单编号为[%s]的权限分发不存在", orderCode));
return new DistributeVO(distribute);
}
}

View File

@ -1,9 +1,5 @@
package club.joylink.rtss.services;
import club.joylink.rtss.exception.BusinessException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.constants.PermissionTypeEnum;
import club.joylink.rtss.constants.StatusEnum;
@ -11,6 +7,7 @@ import club.joylink.rtss.dao.MapInfoDAO;
import club.joylink.rtss.dao.PermissionDAO;
import club.joylink.rtss.dao.SysUserDAO;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.LessonVO;
import club.joylink.rtss.vo.client.PageVO;
@ -19,13 +16,14 @@ import club.joylink.rtss.vo.client.permission.PermissionCreateVO;
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
import club.joylink.rtss.vo.client.permission.PermissionUpdateVO;
import club.joylink.rtss.vo.client.permission.PermissionVO;
import org.springframework.util.StringUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -151,38 +149,29 @@ public class PermissionService implements IPermissionService {
//校验relPermission数量
List<Long> relPermissionIds = createVO.getRelPermissions();
if (relPermissionIds == null || relPermissionIds.size() < 2) {
throw new BusinessException(ExceptionMapping.OPERATION_EXCEPTION, "需要至少两个关联权限");
}
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
relPermissionIds != null && relPermissionIds.size() >= 2, "需要至少两个关联权限"
);
// 校验所选权限是否存在是否是权限包地图id是否相同
Long firstMapid = getById(relPermissionIds.get(0)).getMapId();
for (Long relPermissionsId : relPermissionIds) {
PermissionVO permission = this.getById(relPermissionsId);
if (permission.getIsPackage()) {
throw new BusinessException(ExceptionMapping.OPERATION_EXCEPTION,
String.format("创建权限包异常:权限[%s(%s)]为权限包", permission.getName(), permission.getId()));
}
if (createVO.getMapId() != null) {
if (Objects.equals(createVO.getMapId(), permission.getMapId())) {
throw new BusinessException(ExceptionMapping.OPERATION_EXCEPTION,
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(createVO.getMapId(), permission.getMapId(),
String.format("创建权限包异常:权限[%s(id:%s)]所属地图不相同", permission.getName(), permission.getId()));
}
} else {
if (!getById(relPermissionsId).getMapId().equals(firstMapid)) {
throw new BusinessException(ExceptionMapping.OPERATION_EXCEPTION, "关联权限所属地图不相同");
}
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(getById(relPermissionsId).getMapId(), firstMapid,
"关联权限所属地图不相同");
}
}
// 是否已经存在相同权限包
if (this.isPackageExist(relPermissionIds)) {
throw new BusinessException(ExceptionMapping.DATA_EXISTS, "权限包已存在");
}
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(this.isPackageExist(relPermissionIds), "权限包已存在");
// 拼关联权限字符串
Collections.sort(relPermissionIds);
String relPermissions = StringUtils.join(relPermissionIds, ",");
String relPermissions = StringUtils.arrayToCommaDelimitedString(relPermissionIds.toArray());
//构建权限对象
Permission permission = createVO.convert2DB();
@ -193,7 +182,7 @@ public class PermissionService implements IPermissionService {
return permission.getId().toString();
}
private void confirmNameNotRepeat(String name) throws BusinessException {
private void confirmNameNotRepeat(String name) {
//确认没有重名权限
PermissionExample example = new PermissionExample();
PermissionExample.Criteria criteria = example.createCriteria();
@ -205,9 +194,7 @@ public class PermissionService implements IPermissionService {
@Override
public PermissionVO getById(Long id) {
PermissionVO vo = findById(id);
if (vo == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(vo);
return vo;
}
@ -234,9 +221,7 @@ public class PermissionService implements IPermissionService {
private Permission getEntityById(Long id) {
Permission permission = findEntityById(id);
if (permission == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST, String.format("id为[%s]的权限不存在", id));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(permission, String.format("id为[%s]的权限不存在", id));
return permission;
}
@ -258,10 +243,7 @@ public class PermissionService implements IPermissionService {
public void generatePermission(Long mapId, UserVO user) {
//查询地图
MapInfo mapInfo = this.mapInfoDAO.selectByPrimaryKey(mapId);
if (Objects.isNull(mapInfo)) {
throw new BusinessException(ExceptionMapping.DATA_NOT_EXIST,
String.format("id为[%s]的地图不存在", mapId));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapInfo, String.format("id为[%s]的地图不存在", mapId));
MapVO mapVO = new MapVO(mapInfo);
// 生成基础权限
List<PermissionVO> basePermissionList = createBasePermission(mapVO, user);
@ -286,7 +268,7 @@ public class PermissionService implements IPermissionService {
.map(PermissionVO::getId)
.sorted(Comparator.comparing(Long::longValue))
.collect(Collectors.toList());
String baseIds = StringUtils.join(idList, ",");
String baseIds = StringUtils.arrayToCommaDelimitedString(idList.toArray());
Permission teachingPermissionPackage = findTeachingPermissionByMapId(mapVO.getId());
if (Objects.isNull(teachingPermissionPackage)) { // 不存在创建
teachingPermissionPackage = new Permission();
@ -390,7 +372,7 @@ public class PermissionService implements IPermissionService {
throw new RuntimeException("关联权限id数量至少为2");
}
Collections.sort(relPermissionsIds);
String relIds = StringUtils.join(relPermissionsIds, ",");
String relIds = StringUtils.arrayToCommaDelimitedString(relPermissionsIds.toArray());
PermissionExample example = new PermissionExample();
example.createCriteria()
.andRelPermissionsEqualTo(relIds);
@ -472,7 +454,7 @@ public class PermissionService implements IPermissionService {
@Override
public List<PermissionVO> findPermissionByRelPermissionIds(List<Long> relPermissionIds) {
Collections.sort(relPermissionIds);
String ids = StringUtils.join(relPermissionIds, ",");
String ids = StringUtils.arrayToCommaDelimitedString(relPermissionIds.toArray());
PermissionExample example = new PermissionExample();
example.createCriteria()
.andRelPermissionsEqualTo(ids);
@ -484,9 +466,7 @@ public class PermissionService implements IPermissionService {
@Override
public List<PermissionVO> getPermissionByRelPermissionIds(List<Long> relPermissionIds) {
List<PermissionVO> voList = findPermissionByRelPermissionIds(relPermissionIds);
if (CollectionUtils.isEmpty(voList)) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(voList);
return voList;
}
@ -523,10 +503,7 @@ public class PermissionService implements IPermissionService {
public PermissionVO getTeachPermissionByMapId(Long mapId) {
Permission permission = findTeachingPermissionByMapId(mapId);
if (permission == null) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST,
String.format("id为[%s]的地图下权限包不存在", mapId));
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(permission, String.format("id为[%s]的地图下权限包不存在", mapId));
return new PermissionVO(permission);
}
@ -552,10 +529,8 @@ public class PermissionService implements IPermissionService {
.andMapIdEqualTo(mapId)
.andNameLike(String.format("%%%s%%", "Comprehensive exercise cloud platform"));
List<Permission> permissions = permissionDAO.selectByExample(example);
if (permissions.isEmpty()) {
throw new DBException(ExceptionMapping.DATA_NOT_EXIST,
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions,
String.format("id为[%s]的地图下综合演练权限不存在", mapId));
}
return new PermissionVO(permissions.get(0));
}

View File

@ -296,7 +296,7 @@ public class RunPlanDraftService implements IRunPlanDraftService {
stationRunningExample.createCriteria().andMapIdEqualTo(mapId);
List<MpStationRunning> stationRunningList = this.stationRunningDAO.selectByExample(stationRunningExample);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(stationRunningList, "站间运行数据不存在!");
Map<String, RunPlanLevelVO> levelVOMap = runPlanLevelVOList.stream()
Map<Long, RunPlanLevelVO> levelVOMap = runPlanLevelVOList.stream()
.collect(Collectors.toMap(RunPlanLevelVO::getStationRunningId, Function.identity()));
stationRunningList.forEach(stationRunning -> {
// 查询运行等级

View File

@ -1,23 +1,23 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.dao.DraftMapDAO;
import club.joylink.rtss.dao.DraftMapOverlapDAO;
import club.joylink.rtss.dao.DraftMapRouteDAO;
import club.joylink.rtss.dao.DraftMapRouteFlankProtectionDAO;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.Point;
import club.joylink.rtss.vo.client.map.MapSwitchVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.function.Function;
@ -44,7 +44,7 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
DraftMapWithBLOBs draftMap = this.draftMapDAO.selectByPrimaryKey(mapId);
if (draftMap.getDrawWay()) {
MapGraphDataNewVO graphDataNew;
if (StringUtils.isBlank(draftMap.getGraphData())) {
if (!StringUtils.hasText(draftMap.getGraphData())) {
graphDataNew = new MapGraphDataNewVO();
} else {
graphDataNew = JsonUtils.read(draftMap.getGraphData(), MapGraphDataNewVO.class);
@ -142,7 +142,7 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO);
for (String errMsg : buildResult.getErrMsgList()) {
if (errMsg.contains("道岔")) {
throw BusinessExceptionAssertEnum.MAP_DATA_ERROR.buildException("道岔相关数据有问题,不能计算区段长度");
throw BusinessExceptionAssertEnum.DATA_ERROR.exception("道岔相关数据有问题,不能计算区段长度");
}
}
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
@ -152,9 +152,9 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
.collect(Collectors.toList());
for (Station station : stationList) {
if (!station.isDepot() && station.getKmPostVal() == 0) {
throw BusinessExceptionAssertEnum.MAP_DATA_ERROR.buildException(String.format("车站[%s]没有公里标",station.debugStr()));
throw BusinessExceptionAssertEnum.DATA_ERROR.exception(String.format("车站[%s]没有公里标",station.debugStr()));
} else if (station.getSn()==0) {
throw BusinessExceptionAssertEnum.MAP_DATA_ERROR.buildException(String.format("车站[%s]没有序号",station.debugStr()));
throw BusinessExceptionAssertEnum.DATA_ERROR.exception(String.format("车站[%s]没有序号",station.debugStr()));
}
}
stationList.sort(Comparator.comparing(Station::getSn));
@ -172,7 +172,7 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
}
List<Stand> standList = section.getStandList();
if (CollectionUtils.isEmpty(standList)) {
throw BusinessExceptionAssertEnum.MAP_DATA_ERROR.buildException(String.format("没有站台关联站台轨[%s]",section.debugStr()));
throw BusinessExceptionAssertEnum.DATA_ERROR.exception(String.format("没有站台关联站台轨[%s]",section.debugStr()));
}
boolean right = standList.get(0).isRight();
if (standList.size() > 1) {

View File

@ -1,7 +1,5 @@
package club.joylink.rtss.services.license;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import club.joylink.rtss.configuration.configProp.OtherConfig;
import club.joylink.rtss.dao.LicenseDAO;
import club.joylink.rtss.entity.License;
@ -11,6 +9,8 @@ import club.joylink.rtss.util.AESUtil;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.license.LicenseQueryVO;
import club.joylink.rtss.vo.license.LicenseVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
@ -49,10 +49,10 @@ public class LicenseServiceImpl implements LicenseService {
LicenseVO licenseVO = this.decryptLicense(license);
this.updateLicense(licenseVO);
} else {
throw BusinessExceptionAssertEnum.LICENSE_FILE_NOT_EXIST.buildException("license文件不存在");
throw BusinessExceptionAssertEnum.LICENSE_FILE_NOT_EXIST.exception("license文件不存在");
}
} catch (Exception e) {
throw BusinessExceptionAssertEnum.LICENSE_NOT_EXIST.buildException(e);
throw BusinessExceptionAssertEnum.LICENSE_NOT_EXIST.exception(e);
}
}
@ -62,7 +62,7 @@ public class LicenseServiceImpl implements LicenseService {
LicenseVO licenseVO = LicenseVO.fromJson(json);
return licenseVO;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.LICENSE_DECRYPT_FAILED.buildException(String.format("license解密/转换异常"), e);
throw BusinessExceptionAssertEnum.LICENSE_DECRYPT_FAILED.exception(String.format("license解密/转换异常"), e);
}
}
@ -86,7 +86,7 @@ public class LicenseServiceImpl implements LicenseService {
FileCopyUtils.copy(Base64.getDecoder().decode(license), licenseFileResource.getFile());
}
} catch (IOException e) {
throw BusinessExceptionAssertEnum.LICENSE_LOCAL_SAVE_FAILED.buildException(String.format("本地license文件写入异常"), e);
throw BusinessExceptionAssertEnum.LICENSE_LOCAL_SAVE_FAILED.exception(String.format("本地license文件写入异常"), e);
}
}
@ -95,7 +95,7 @@ public class LicenseServiceImpl implements LicenseService {
LicenseVO licenseVO = this.decryptLicense(license);
BusinessExceptionAssertEnum.INVALID_LICENSE.assertTrue(Objects.nonNull(licenseVO) && licenseVO.isValid() && !licenseVO.isExpire());
} catch (Throwable e) {
throw BusinessExceptionAssertEnum.INVALID_LICENSE.buildException(e);
throw BusinessExceptionAssertEnum.INVALID_LICENSE.exception(e);
}
}

View File

@ -1,46 +0,0 @@
package club.joylink.rtss.simulation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Service
public class SimulationManageService {
private static final Map<String, Simulation> simulationMap = new ConcurrentHashMap<>();
@Autowired
private TestLogicService testLogicService;
public Simulation createSimulation(String id) {
CbtcSimulation cbtcSimulation = new CbtcSimulation(id);
simulationMap.put(id, cbtcSimulation);
cbtcSimulation.addJob("1+2", ()->{
Thread.sleep(2000);
}, 1000);
cbtcSimulation.addJob("5+6", ()->{
int add = 5 + 6;
System.out.println(add);
}, 500);
return cbtcSimulation;
}
public static void main(String[] args) {
SimulationManageService service = new SimulationManageService();
for (int i = 0; i < 1; i++) {
Simulation simulation = service.createSimulation(String.valueOf(i + 1));
// for (int j = 0; j < 3; j++) {
// int idx = j + 1;
// simulation.addJob(String.format("job-%s", idx), ()->{
// System.out.println(String.format("simulation [%s] job-%s execute!", simulation.getId(), idx));
// }, 1000/idx);
// }
}
for (Simulation simulation : simulationMap.values()) {
simulation.start();
// simulation.updateSpeed(8);
}
}
}

View File

@ -47,7 +47,6 @@ import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.runplan.*;
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
import club.joylink.rtss.vo.client.script.ScriptVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO;
import club.joylink.rtss.vo.client.simulationv1.*;
import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.websocket.StompMessageService;
@ -117,9 +116,6 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Autowired
private StompMessageService stompMessageService;
@Autowired
private club.joylink.rtss.services.IScriptService scriptService;
@Autowired
private IScriptService iScriptService;
@ -604,7 +600,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
public void loadScript(Simulation simulation, Long scriptId) {
ScriptVO detailById = iScriptService.getDetailById(scriptId);
this.loadScenes(simulation.getGroup(), detailById.getBgScenesJson());
ScriptBO scriptBO = scriptService.getScriptBOById(scriptId, simulation);
ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation);
iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO);
SocketMessageVO<Boolean> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Script_Loaded,
simulation.getGroup(), true);

View File

@ -1,227 +0,0 @@
package club.joylink.rtss.vo.client.plc;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.math.BigInteger;
import java.util.Objects;
@Getter
@Setter
@NoArgsConstructor
public class PLCConfigVO {
@ApiModelProperty(value = "单元id")
private short unitId;
@ApiModelProperty(value = "开屏蔽门的输出寄存器地址")
private String outAddrOpenDoor;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outOpenDoor;
@ApiModelProperty(value = "关屏蔽门的输出寄存器地址")
private String outAddrCloseDoor;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outCloseDoor;
@ApiModelProperty(value = "设置屏蔽门关门状态输出寄存器地址")
private String outAddrDoorCloseStatusSet;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outCloseStatusSet;
@ApiModelProperty(value = "屏蔽门锁闭输出寄存器地址")
private String outAddrLockDoor;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outLockDoor;
@ApiModelProperty(value = "屏蔽门开门状态信号灯输出寄存器地址")
private String outAddrDoorOpenSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outOpenSignal;
@ApiModelProperty(value = "屏蔽门关门状态信号灯输出寄存器地址")
private String outAddrDoorCloseSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outCloseSignal;
@ApiModelProperty(value = "屏蔽门关门并锁闭状态信号灯输出寄存器地址")
private String outAddrDoorCloseAndLockSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outCloseLockSignal;
@ApiModelProperty(value = "PSL操作指示灯输出寄存器地址")
private String outAddrPSLSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outPSLSignal;
@ApiModelProperty(value = "互锁解除指示灯输出寄存器地址")
private String outAddrInterlockReleaseSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer outInterlockReleaseSignal;
@ApiModelProperty(value = "屏蔽门是否关门输入寄存器位值")
private String inValDoorClose;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inDoorClose;
@ApiModelProperty(value = "屏蔽门是否锁闭输入寄存器位值")
private String inValDoorLock;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inDoorLock;
@ApiModelProperty(value = "PSL操作允许输入寄存器位值")
private String inValPSLOperate;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inPSLOperate;
@ApiModelProperty(value = "互锁解除输入寄存器位值")
private String inValInterlockRelease;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inInterlockRelease;
@ApiModelProperty(value = "开门按钮按下输入寄存器位值")
private String inValOpenDoor;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inOpenDoor;
@ApiModelProperty(value = "关门按钮按下输入寄存器位值")
private String inValCloseDoor;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inCloseDoor;
@ApiModelProperty(value = "试灯按钮按下输入寄存器位值")
private String inValTestSignal;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer inTestSignal;
/** 开门/关门指令 */
@ApiModelProperty(hidden = true)
@JsonIgnore
private Boolean openCommand;
/** 真实屏蔽门完全关门剩余时间 */
@ApiModelProperty(hidden = true)
@JsonIgnore
private Float realDoorCloseRemain;
public void openRealDoorStart() {
this.openCommand = true;
}
public void closeRealDoorStart() {
this.openCommand = false;
}
public void realDoorActionOver(boolean open) {
if(Objects.equals(this.getOpenCommand(), open)) {
this.openCommand = null;
}
}
public void realDoorCloseStart() {
this.realDoorCloseRemain = VirtualScreenDoor.XTY_Screen_Door_Close_Time;
}
public void updateRealDoorCloseRemain(float remainTime) {
this.realDoorCloseRemain = remainTime;
}
public void realDoorCloseEnd() {
this.realDoorCloseRemain = null;
}
public boolean isRealDoorClosing() {
return Objects.nonNull(this.realDoorCloseRemain);
}
public void transform() {
try {
this.outOpenDoor = new BigInteger(this.outAddrOpenDoor, 16).intValue();
this.outCloseDoor = new BigInteger(this.outAddrCloseDoor, 16).intValue();
this.outLockDoor = new BigInteger(this.outAddrLockDoor, 16).intValue();
this.outOpenSignal = new BigInteger(this.outAddrDoorOpenSignal, 16).intValue();
this.outCloseStatusSet = new BigInteger(this.outAddrDoorCloseStatusSet, 16).intValue();
this.outCloseSignal = new BigInteger(this.outAddrDoorCloseSignal, 16).intValue();
this.outCloseLockSignal = new BigInteger(this.outAddrDoorCloseAndLockSignal, 16).intValue();
this.outPSLSignal = new BigInteger(this.outAddrPSLSignal, 16).intValue();
this.outInterlockReleaseSignal = new BigInteger(this.outAddrInterlockReleaseSignal, 16).intValue();
this.inDoorClose = new BigInteger(this.inValDoorClose, 16).intValue();
this.inDoorLock = new BigInteger(this.inValDoorLock, 16).intValue();
this.inPSLOperate = new BigInteger(this.inValPSLOperate, 16).intValue();
this.inInterlockRelease = new BigInteger(this.inValInterlockRelease, 16).intValue();
this.inOpenDoor = new BigInteger(this.inValOpenDoor, 16).intValue();
this.inCloseDoor = new BigInteger(this.inValCloseDoor, 16).intValue();
this.inTestSignal = new BigInteger(this.inValTestSignal, 16).intValue();
} catch (Exception e) {
throw new BusinessException(ExceptionMapping.DATA_EXCEPTION.getErrcode(), "plc网关配置数据异常", e);
}
}
/**
* 指定的位是否为1
* @param val
* @param oldValue
* @return
*/
public static boolean isOn(Integer val, Integer oldValue) {
Objects.requireNonNull(val);
Objects.requireNonNull(oldValue);
if((val & oldValue) == val) {
return true;
}
return false;
}
public int build(Integer... args) {
int val = 0;
for (int i = 0; i < args.length; i++) {
val = val | args[i];
}
return val;
}
@JsonIgnore
public int getAllPslSignalOutVal() {
return this.build(this.outCloseSignal,
this.outOpenSignal,
this.outPSLSignal,
this.outCloseLockSignal,
this.outInterlockReleaseSignal);
}
}

View File

@ -1,79 +0,0 @@
package club.joylink.rtss.vo.client.plc;
import com.fasterxml.jackson.annotation.JsonIgnore;
import club.joylink.rtss.entity.PlcConfig;
import club.joylink.rtss.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Getter
@Setter
@NoArgsConstructor
@ApiModel(value = "PLC网关配置")
public class PLCGatewayConfigVO {
private Long id;
@ApiModelProperty(value = "网关id")
@NotBlank(message = "gatewayId不能为空")
private String gatewayId;
@ApiModelProperty(value = "网关所属group")
@NotBlank(message = "所属group不能为空")
private String group;
@ApiModelProperty(value = "网关名称")
private String gatewayName;
@ApiModelProperty(value = "屏蔽门plc控制器配置")
private PLCConfigVO plcConfig;
public PLCGatewayConfigVO(PlcConfig config) {
this.id = config.getId();
this.gatewayId = config.getGatewayId();
this.group = config.getGroup();
this.gatewayName = config.getGatewayName();
if(!StringUtils.isEmpty(config.getPlcConfig())) {
this.plcConfig = JsonUtils.read(config.getPlcConfig(), PLCConfigVO.class);
this.plcConfig.transform();
}
}
public static List<PLCGatewayConfigVO> convert2VO(List<PlcConfig> list) {
List<PLCGatewayConfigVO> voList = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)) {
list.forEach(config -> voList.add(new PLCGatewayConfigVO(config)));
}
return voList;
}
public PlcConfig toDB() {
PlcConfig config = new PlcConfig();
config.setId(this.id);
config.setGatewayId(this.getGatewayId());
config.setGroup(this.getGroup());
config.setGatewayName(this.getGatewayName());
if(Objects.nonNull(this.getPlcConfig())) {
config.setPlcConfig(JsonUtils.writeValueAsString(this.getPlcConfig()));
}
return config;
}
@JsonIgnore
public String getPlcConfigJson() {
if(Objects.nonNull(this.getPlcConfig())) {
return JsonUtils.writeValueAsString(this.getPlcConfig());
}
return null;
}
}