Merge remote-tracking branch 'origin/test-training2' into test-training2

This commit is contained in:
joylink_zhangsai 2022-12-01 16:42:48 +08:00
commit ce4744f519
17 changed files with 213 additions and 123 deletions

View File

@ -79,6 +79,7 @@ CREATE TABLE `rts_permission_subject` (
`start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`distribute_id` bigint NOT NULL COMMENT '来自对应的分发id(rts_permission_distribute)',
`parent_id` bigint NULL DEFAULT NULL COMMENT '父级id 数据来源rts_permission_distribute表source_subject_id字段',
PRIMARY KEY (`id`) USING BTREE

View File

@ -2,13 +2,11 @@ package club.joylink.rtss.dao.permission;
import club.joylink.rtss.entity.permission.PermissionSubject;
import club.joylink.rtss.entity.permission.PermissionSubjectExample;
import club.joylink.rtss.vo.permission.PermissionDistributeStatusEnum;
import club.joylink.rtss.vo.permission.PermissionSubjectStatusEnum;
import club.joylink.rtss.vo.permission.subject.PermissionSubjectQueryVO;
import club.joylink.rtss.vo.permission.subject.PermissionSubjectVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -74,6 +72,13 @@ public interface PermissionSubjectDAO {
" order by id desc " +
"</script>")
List<PermissionSubjectVO> customerQuery(@Param("vo") PermissionSubjectQueryVO queryVO);
/**
* 状态参考 {@link PermissionSubjectStatusEnum}
*/
@Update("<script> update rts_permission_subject set status = 2,update_time = now() where forever = 0 and (`status` is null or `status` = 1) " +
" <![CDATA[ and end_time < now() ]]> </script>")
void updateStatusByTimeOver();
long countByExample(PermissionSubjectExample example);
int deleteByExample(PermissionSubjectExample example);

View File

@ -6,12 +6,10 @@ import club.joylink.rtss.entity.permission.RtsDistributeExample;
import java.time.LocalDateTime;
import java.util.List;
import club.joylink.rtss.vo.permission.PermissionDistributeStatusEnum;
import club.joylink.rtss.vo.permission.distribute.DistributeDataVO;
import club.joylink.rtss.vo.permission.distribute.DistributeQueryVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@Mapper
@ -37,6 +35,11 @@ public interface RtsDistributeDAO {
" #{record.dsc,jdbcType=VARCHAR},#{record.isSync,jdbcType=BIT})</script>")
void customerSyncInsert(@Param("record") RtsDistribute record);
/**
* 状态参考 {@link PermissionDistributeStatusEnum}
*/
@Update("<script>update rts_distribute set status = 2,update_time = now() where forever = 0 and (`status` is null or `status` = 1) <![CDATA[ and end_time < now() ]]></script>")
void updateStatusByTimeOver();
long countByExample(RtsDistributeExample example);
int deleteByExample(RtsDistributeExample example);

View File

@ -19,6 +19,12 @@ public interface RtsPermissionDistributeRefDAO {
" where 1 = 1 and A.distribute_id = #{disId}" +
"</script>")
List<DistributeDataVO.DistributePermissionVO> selectByDisId(Long disId);
@Select("<script>select A.permission_id,B.name as permissionName,A.amount,A.remains " +
" from rts_permission_distribute_ref A left join rts_permission B on A.permission_id = B.id " +
" where 1 = 1 and A.distribute_id = #{disId}" +
"</script>")
List<DistributeDataVO.DistributePermissionVO> selectTimeOut();
long countByExample(RtsPermissionDistributeRefExample example);
int deleteByExample(RtsPermissionDistributeRefExample example);

View File

@ -14,6 +14,7 @@ import java.util.List;
@Repository
public interface SyncDAO {
List<UserPermissionVO> findCanUsedData();
List<UserPermissionVO> findPackageData(List<Long> idList);
@Delete("<script>delete from rts_permission where is_sync = 1</script>")
void clearRtsPermission();

View File

@ -13,6 +13,7 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.permission.PermissionDistributeStatusEnum;
import club.joylink.rtss.vo.permission.PermissionSubjectStatusEnum;
import club.joylink.rtss.vo.permission.PermissionSubjectTypeEnum;
import club.joylink.rtss.vo.permission.convertor.PermissionDistributeConvertor;
import club.joylink.rtss.vo.permission.distribute.DistributeDataVO;
@ -28,6 +29,7 @@ import org.springframework.util.StringUtils;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -185,4 +187,11 @@ public class DistributeService implements IDistributeService{
this.distributeRefDAO.updateByExampleSelective(ref,refExample);
}
}
@Override
@Transactional
public void resetRistrbuteStatus() {
this.rtsDistributeDAO.updateStatusByTimeOver();
this.permissionSubjectDAO.updateStatusByTimeOver();
}
}

View File

@ -56,4 +56,9 @@ public interface IDistributeService {
*/
void subjectAcceptFromPermissionDistribute(Long pdId, PermissionSubjectTypeEnum subjectType, Long subjectId);
/**
* 查询超时的权限分发并且重置对应的状态
*/
void resetRistrbuteStatus();
}

View File

@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionGenerateParamVO;
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
import club.joylink.rtss.vo.client.permission.PermissionVO;
import club.joylink.rtss.vo.permission.PermissionDistributeStatusEnum;
import club.joylink.rtss.vo.permission.PermissionSubjectStatusEnum;
import club.joylink.rtss.vo.permission.PermissionSubjectTypeEnum;
import club.joylink.rtss.vo.permission.PermissionTypeEnum;
@ -117,10 +118,8 @@ public class OldPermissionDataSyncService {
@Transactional(rollbackFor = Exception.class)
public File sync(){
try{
List<UserPermissionVO> userPermissionList = syncDAO.findCanUsedData();
List<UserPermissionVO> userPermissionList = findUserPermissionData();
Map<Long,List<SystemAbility>> funMapIdMap = this.findSystemAbilityGroupMapId();
List<SyncVO> syncVOList = findAllPermission(userPermissionList,funMapIdMap);
List<DistributeDataVO> distributeDataVOList = distributeData(syncVOList);
@ -136,8 +135,24 @@ public class OldPermissionDataSyncService {
}finally {
ISRUN.compareAndSet(true,false);
}
}
private List<UserPermissionVO> findUserPermissionData(){
List<UserPermissionVO> userPermissionList = syncDAO.findCanUsedData();
List<UserPermissionVO> newList = Lists.newArrayList();
userPermissionList.forEach(d->{
if(Objects.isNull(d.getForever())){
d.setForever(false);
}
if(d.getForever()){
newList.add(d);
}else if(d.getEndTime().isAfter(LocalDateTime.now())){
newList.add(d);
}
// newList.add(d);
});
return newList;
}
private File outErrorMsg(){
@ -176,13 +191,22 @@ public class OldPermissionDataSyncService {
}
private void insertPermission(List<SyncVO> syncVOList){
Set<Long> existPermissSet = Sets.newHashSet();
List<PermissionSystemAbility> allSaList = Lists.newArrayList();
for (SyncVO syncVO : syncVOList) {
syncVO.permission.setIsSync(true);
this.acPermissionDAO.customerSyncInsert(syncVO.permission);
syncVO.getSystemAbility().forEach(d->d.setIsSync(true));
if(existPermissSet.add(syncVO.getPermission().getId())){
this.acPermissionDAO.customerSyncInsert(syncVO.permission);
allSaList.addAll(syncVO.getSystemAbility());
// this.permissionSystemAbilityDAO.batchInsert(syncVO.getSystemAbility());
}
}
// List<PermissionSystemAbility> tmpList = syncVOList.stream().map(d->d.getSystemAbility()).flatMap(d->d.stream()).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(allSaList)){
this.permissionSystemAbilityDAO.batchInsert(allSaList);
}
List<PermissionSystemAbility> tmpList = syncVOList.stream().map(d->d.getSystemAbility()).flatMap(d->d.stream()).collect(Collectors.toList());
this.permissionSystemAbilityDAO.batchInsert(tmpList);
}
private void insertDistribute(List<DistributeDataVO> distributeDataVOList){
@ -227,8 +251,11 @@ public class OldPermissionDataSyncService {
Set<Long> existId = new HashSet<>();
List<DistributeDataVO> datavoList = Lists.newArrayList();
for (SyncVO vo : syncVOList) {
if(existId.add(vo.getDistributeId())){
DistributeDataVO dataVO = SyncConvertUtil.createDistributeDataVO(vo);
if(Objects.isNull(vo.getDistributeId())){
datavoList.add(dataVO);
}else if(existId.add(vo.getDistributeId())){
datavoList.add(dataVO);
}
}
@ -238,7 +265,8 @@ public class OldPermissionDataSyncService {
private List<SyncVO> findAllPermission(List<UserPermissionVO> userPermissionList,Map<Long,List<SystemAbility>> funMapIdMap){
List<UserPermissionVO> handleDataList = this.easyBeforehand(userPermissionList);
List<SyncVO> syncVOList = Lists.newArrayList();
Set<Long> existPermissionIdSet = Sets.newHashSet();
// Set<Long> existPermissionIdSet = Sets.newHashSet();
Set<String> existPermissionIdSet = Sets.newHashSet();
for (UserPermissionVO permissionVO : handleDataList) {
List<SystemAbility> mapList = funMapIdMap.get(permissionVO.getMapId());
if(CollectionUtils.isEmpty(mapList)){
@ -246,7 +274,8 @@ public class OldPermissionDataSyncService {
SYNC_RESULT_LIST.add(new ErrorMsgVO(ErrorType.PERSSION_NOTFIND_MAP,permissionVO,String.format("mapid[%s] 未在 rts_permission_system_ability 表中找到对应的数据",permissionVO.getMapId())));
continue;
}
if(!existPermissionIdSet.add(permissionVO.getPermissionId())){
if(!existPermissionIdSet.add(permissionVO.getPermissionId() + "," + permissionVO.getDistributeId())){
continue;
}
Permission permission = SyncConvertUtil.convertSyncPermissionFromPermissionVO(permissionVO);
@ -336,10 +365,22 @@ public class OldPermissionDataSyncService {
for (UserPermissionVO userPermissionVO : packAgeVOList) {
List<Long> idLists = Splitter.on(",").omitEmptyStrings().trimResults().splitToStream(userPermissionVO.getRelPermissions()).map(Long::parseLong).collect(Collectors.toList());
idLists.remove(userPermissionVO.getPermissionId());
/* List<UserPermissionVO> userPermissionVOS = this.syncDAO.findPackageData(idLists);
for (UserPermissionVO vo : userPermissionVOS) {
vo.setStartTime(userPermissionVO.getStartTime());
vo.setEndTime(userPermissionVO.getEndTime());
vo.setUserId(userPermissionVO.getUserId());
vo.setForever(userPermissionVO.getForever());
vo.setAmount(userPermissionVO.getAmount());
vo.setRemains(userPermissionVO.getRemains());
}
voList.addAll(userPermissionVOS);*/
PermissionQueryVO queryVO = new PermissionQueryVO();
queryVO.setInIds(idLists);
List<PermissionVO> permissionVOList = this.iPermissionService.queryPermission(queryVO);
userPermissionVO.setPermissionVO(permissionVOList);
}
voList.addAll(packAgeVOList);
}
@ -402,6 +443,7 @@ public class OldPermissionDataSyncService {
dataVO.setForever(vo.forever);
dataVO.setStartTime(vo.getStartTime());
dataVO.setEndTime(vo.getEndTime());
dataVO.setStatus(PermissionDistributeStatusEnum.Valid.getValue());
DistributeDataVO.DistributePermissionVO dpVO = new DistributeDataVO.DistributePermissionVO();
dpVO.setPermissionId(vo.getPermission().getId());
dpVO.setDistributeId(vo.getDistributeId());

View File

@ -30,7 +30,7 @@ public class TrainPositionService {
public void initTrainOrUpdate(String mapName,String json){
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
tp.setReceiveTime(System.currentTimeMillis());
log.info(json);
log.debug(json);
// SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
// this.messageService.send(vo);
this.timeOverService.addTrainAccept(mapName,tp);

View File

@ -103,7 +103,7 @@ public class TrainPositionTimeOverService {
}
if(tp.receiveTimeOver(this.receiveTimeOver)){
if(Objects.isNull(tp.getGroupNum())){
log.error("错误的数据:" + tp);
log.debug("错误的数据:" + tp);
continue;
}
if(checkExist(key,simulation)){
@ -120,7 +120,7 @@ public class TrainPositionTimeOverService {
List<Section> sectionList = findDirectionAllSection(simulation,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",tp);
log.debug("未找到对应的区段 param:{}",tp);
continue;
}
this.newAtsTrainLoadService.loadTripNumberTrain(simulation,tp,section);

View File

@ -9,6 +9,7 @@ import club.joylink.rtss.entity.UserPermission;
import club.joylink.rtss.entity.UserPermissionExample;
import club.joylink.rtss.services.IPermissionDistributeService;
import club.joylink.rtss.services.IUserPermissionService;
import club.joylink.rtss.services.permission.IDistributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@ -18,6 +19,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 课程权限定时回收任务
@ -39,10 +41,19 @@ public class PmsPermissionRestoreTask {
@Autowired
private IPermissionDistributeService iPermissionDistributeService;
@Autowired
private IDistributeService newDistributeService;
/**
* 定时回收权限数据
*
*/
@Scheduled(fixedRate = 10000)
@Scheduled(fixedRate =60 * 60 * 1000)
public void newRestore() {
this.newDistributeService.resetRistrbuteStatus();
}
// @Scheduled(fixedRate = 10000)
public void restore() {
this.restorePermission();
this.restoreDistribute();

View File

@ -10,7 +10,7 @@ import java.util.List;
@Data
@ToString
public class UserPermissionVO {
private Long id;
// private Long id;
private Long permissionId;
private Long distributeId;
private LocalDateTime startTime;

View File

@ -5,121 +5,82 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
import lombok.Getter;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Getter
public enum MapDeviceRule {
ROUTE_LIST("普通进路列表") {
METRO_ROUTE_LIST("地铁进路利列表") {
@Override
public List<Route> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
boolean isMETRO = Simulation.Type.METRO.equals(simulation.getBuildParams().getWorkParamVO().getType());
if (!isMETRO) {
return List.of();
}
Station station = stationList.get(0);
// 获取本站的2个进路信息
return simulation.getRepository().getRouteList().stream().filter(r -> station.equals(r.getStart().getStation()))
.limit(1).collect(Collectors.toList());
List<Route> routeList = simulation.getRepository().getRouteList().stream()
.filter(r -> Signal.SignalType.PROTECTION.equals(r.getStart().getType())).collect(Collectors.toList());
return generateRandomElement(routeList, 2);
}
},
RAILWAY_PICK_ROUTE_LIST("大铁接车进路列表") {
@Override
public List<Route> filterMapDeviceList(Simulation simulation) {
boolean isRailWay = Simulation.Type.RAILWAY.equals(simulation.getBuildParams().getWorkParamVO().getType());
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList) || !isRailWay) {
if (!isRailWay) {
return List.of();
}
Station station = stationList.get(0);
// 获取本站的2个进路信息
return simulation.getRepository().getRouteList().stream()
.filter(r -> Objects.equals(r.getType(), Route.Type.RECEIVING) && station.equals(r.getStart().getStation()))
.limit(1).collect(Collectors.toList());
List<Route> routeList = simulation.getRepository().getRouteList().stream()
.filter(r -> Objects.equals(r.getType(), Route.Type.RECEIVING)).collect(Collectors.toList());
return generateRandomElement(routeList, 2);
}
},
STATION_LIST("车站列表") {
@Override
public List<Station> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
return stationList.stream().limit(1).collect(Collectors.toList());
return generateRandomElement(stationList, 1);
}
},
SWITCH_LIST("道岔列表") {
@Override
public List<Switch> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
Station station = stationList.get(0);
return simulation.getRepository().getSwitchList().stream()
.filter(s -> station.equals(s.getDeviceStation())).limit(1).collect(Collectors.toList());
List<Switch> switchList = simulation.getRepository().getSwitchList();
return generateRandomElement(switchList, 2);
}
},
SIGNAL_LIST("信号机列表") {
@Override
public List<Signal> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
Station station = stationList.get(0);
return simulation.getRepository().getSignalList().stream()
.filter(s -> station.equals(s.getDeviceStation())).limit(1).collect(Collectors.toList());
List<Signal> signalList = simulation.getRepository().getSignalList();
return generateRandomElement(signalList, 2);
}
},
RAILWAY_DEPARTURE_SIGNAL_LIST("大铁发车信号机列表") {
@Override
public List<Signal> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
Station station = stationList.get(0);
return simulation.getRepository().getSignalList().stream()
.filter(s -> Signal.SignalType.DEPARTURE.equals(s.getType()) && station.equals(s.getDeviceStation()))
.limit(1).collect(Collectors.toList());
List<Signal> signalList = simulation.getRepository().getSignalList().stream()
.filter(s -> Signal.SignalType.DEPARTURE.equals(s.getType())).collect(Collectors.toList());
return generateRandomElement(signalList, 2);
}
},
SECTION_LIST("普通区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
Station station = stationList.get(0);
return simulation.getRepository().getSectionList().stream()
.filter(s -> s.getParent() == null && station.equals(s.getDeviceStation()))
.limit(1).collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(s -> s.getParent() == null).collect(Collectors.toList());
return generateRandomElement(sectionList, 2);
}
},
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
// 只获取一个车站的
List<Station> stationList = simulation.getRepository().getStationList();
if (CollectionUtils.isEmpty(stationList)) {
return List.of();
}
Station station = stationList.get(0);
return simulation.getRepository().getSectionList().stream()
.filter(s -> s.isSwitchTrack() && station.equals(s.getDeviceStation()))
.limit(1).collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(Section::isSwitchTrack).collect(Collectors.toList());
return generateRandomElement(sectionList, 2);
}
}
;
@ -131,4 +92,24 @@ public enum MapDeviceRule {
}
public abstract <T extends MapNamedElement> List<T> filterMapDeviceList(Simulation simulation);
/**
* 获取列表中随机元素
* @param sourceList 总元素列表
* @param length 随机元素个数
* @return 生成的元素列表
* @param <T> 元素类型
*/
private static <T extends MapNamedElement> List<T> generateRandomElement(List<T> sourceList, int length) {
List<T> givenList = new ArrayList<>(length);
Random rand = new Random();
for (int size = sourceList.size(), i = 0; size > 0 && i < length; size--, i++) {
int randomIndex = rand.nextInt(size);
T randomElement = sourceList.get(randomIndex);
sourceList.set(randomIndex, sourceList.get(size - 1));
sourceList.set(size - 1 , randomElement);
givenList.add(randomElement);
}
return givenList;
}
}

View File

@ -0,0 +1,40 @@
package club.joylink.rtss.vo.training2.rule;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
/**
* 实训获取元素属性的公共代码生成实训时使用
*/
public abstract class MapElementRule {
/**
* 获取地图元素的车站
*
* @param mapElement 地图元素
* @return 车站信息
*/
public static Station queryStation(Object mapElement) {
if (mapElement instanceof Route) {
Route route = (Route) mapElement;
if (route.getInterlockStation() != null) {
return route.getInterlockStation();
} else {
Signal signal = route.getStart();
if (signal.getStation() != null) {
return signal.getStation();
} else {
return signal.getDeviceStation();
}
}
} else if (mapElement instanceof Signal) {
return ((Signal) mapElement).getDeviceStation();
} else if (mapElement instanceof Station) {
return (Station) mapElement;
} else if (mapElement instanceof Switch) {
return ((Switch) mapElement).getDeviceStation();
}
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
}
}

View File

@ -7,6 +7,8 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
@ -29,19 +31,7 @@ public enum MapLocationRule {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
MapGraphDataNewVO mapGraphDataNewVO = simulation.getBuildParams().getMap().getGraphDataNew();
String stationCode = null;
if (mapElement instanceof Route) {
stationCode = ((Route) mapElement).getStart().getStation().getCode();
} else if (mapElement instanceof Signal) {
stationCode = ((Signal) mapElement).getDeviceStation().getCode();
} else if (mapElement instanceof Station) {
stationCode = mapElement.getCode();
} else if (mapElement instanceof Switch) {
stationCode = ((Switch) mapElement).getDeviceStation().getCode();
}
if (StringUtils.isEmpty(stationCode)) {
return null;
}
String stationCode = MapElementRule.queryStation(mapElement).getCode();
// 获取第一个站
MapStationNewVO firstStation = mapGraphDataNewVO.getStationList().stream()
.sorted(Comparator.comparingInt(MapStationNewVO::getSn)).findFirst().get();

View File

@ -28,33 +28,13 @@ public enum PropertyValueRule {
STATION_NAME("地图设备所属车站名称") {
@Override
public String resolve(Simulation simulation, Object mapElement) {
if (mapElement instanceof Route) {
return ((Route) mapElement).getStart().getStation().getName();
} else if (mapElement instanceof Signal) {
return ((Signal) mapElement).getDeviceStation().getName();
} else if (mapElement instanceof Station) {
return ((Station) mapElement).getName();
} else if (mapElement instanceof Switch) {
return ((Switch) mapElement).getDeviceStation().getName();
}
return null;
return MapElementRule.queryStation(mapElement).getName();
}
},
STATION_CODE("地图设备所属车站编码") {
@Override
public String resolve(Simulation simulation, Object mapElement) {
if (mapElement instanceof Route) {
return ((Route) mapElement).getStart().getStation().getCode();
} else if (mapElement instanceof Signal) {
return ((Signal) mapElement).getDeviceStation().getCode();
} else if (mapElement instanceof Station) {
return ((Station) mapElement).getCode();
} else if (mapElement instanceof Switch) {
return ((Switch) mapElement).getDeviceStation().getCode();
} else if (mapElement instanceof Section) {
return ((Section) mapElement).getDeviceStation().getCode();
}
return null;
return MapElementRule.queryStation(mapElement).getCode();
}
},
ROUTE_START_SIGNAL_NAME("进路起始名称") {

View File

@ -8,5 +8,21 @@
from user_permission A left join permission B on A.permission_id = B.id
left join map_info C on B.map_id = C.id
where 1 = 1 and C.id is not null and C.status = '1'
</select>
<select id="findPackageData" parameterType="arraylist" resultType="club.joylink.rtss.vo.permission.sync.UserPermissionVO">
select B.id as permission_id,null as distribute_id,null as start_time, null as end_time,null as user_id,trim(B.name) as permission_name
,C.id as map_id,B.create_time,B.update_time,B.remarks,B.creator_id,B.type,B.prd_id,B.prd_type,B.is_package,B.rel_permissions
,null as forever, null as amount, null as remains,C.name as map_name
from
permission B
left join map_info C on B.map_id = C.id
where 1 = 1 and C.id is not null and C.status = '1'
and B.id in
<foreach collection="idList" open=" ( " close=")" separator="," item="d">
${d}
</foreach>
</select>
</mapper>