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

This commit is contained in:
joylink_zhangsai 2021-05-27 13:34:42 +08:00
commit 5e818e06ec
31 changed files with 599 additions and 208 deletions

View File

@ -34,8 +34,8 @@ public class AuthenticateInterceptor implements HandlerInterceptor {
throws Exception {
// 登陆权限验证
if(RequestMethod.OPTIONS.name().equals(request.getMethod())) return true;
log.debug(String.format("request[Method: '%s', RequestURI: '%s']",
request.getMethod(), request.getRequestURI()));
log.debug(String.format("request[%s %s from:%s]",
request.getMethod(), request.getRequestURI(), request.getRemoteAddr()));
String token = request.getHeader("X-Token");
BusinessExceptionAssertEnum.NOT_LOGIN.assertTrue(StringUtils.hasText(token));
LoginUserInfoVO loginUserInfoVO = null;

View File

@ -342,38 +342,38 @@ public class DraftMapController {
}
/*-------------- 延续保护 ------------------*/
@ApiOperation(value = "创建延续保护")
@PostMapping(path = "/overlap")
public void createOverlap(@RequestBody @Validated MapOverlapVO mapOverlapVO) {
this.iDraftMapService.createOverlap(mapOverlapVO);
}
@ApiOperation(value = "分页查询延续保护列表")
@GetMapping(path = "/{mapId}/overlap/paging")
public PageVO<MapOverlapVO> queryPagedOverlap(
@PathVariable Long mapId,
MapOverlapQueryVO queryVO) {
return this.iDraftMapService.queryPagedOverlap(mapId, queryVO);
}
@ApiOperation(value = "根据id查询延续保护")
@GetMapping(path = "/overlap/{id}")
public MapOverlapVO getOverlapById(@PathVariable Long id) {
return this.iDraftMapService.getOverlapById(id);
}
@ApiOperation(value = "更新延续保护")
@PutMapping(path = "/overlap/{id}")
public void updateOverlap(@PathVariable Long id, @RequestBody @Validated MapOverlapVO mapOverlapVO) {
this.iDraftMapService.updateOverlap(id, mapOverlapVO);
}
@ApiOperation(value = "删除延续保护")
@DeleteMapping(path = "/overlap/{id}")
public void deleteOverlap(@PathVariable Long id) {
this.iDraftMapService.deleteOverlap(id);
}
//
// @ApiOperation(value = "创建延续保护")
// @PostMapping(path = "/overlap")
// public void createOverlap(@RequestBody @Validated MapOverlapVO mapOverlapVO) {
// this.iDraftMapService.createOverlap(mapOverlapVO);
// }
//
// @ApiOperation(value = "分页查询延续保护列表")
// @GetMapping(path = "/{mapId}/overlap/paging")
// public PageVO<MapOverlapVO> queryPagedOverlap(
// @PathVariable Long mapId,
// MapOverlapQueryVO queryVO) {
// return this.iDraftMapService.queryPagedOverlap(mapId, queryVO);
// }
//
// @ApiOperation(value = "根据id查询延续保护")
// @GetMapping(path = "/overlap/{id}")
// public MapOverlapVO getOverlapById(@PathVariable Long id) {
// return this.iDraftMapService.getOverlapById(id);
// }
//
// @ApiOperation(value = "更新延续保护")
// @PutMapping(path = "/overlap/{id}")
// public void updateOverlap(@PathVariable Long id, @RequestBody @Validated MapOverlapVO mapOverlapVO) {
// this.iDraftMapService.updateOverlap(id, mapOverlapVO);
// }
//
// @ApiOperation(value = "删除延续保护")
// @DeleteMapping(path = "/overlap/{id}")
// public void deleteOverlap(@PathVariable Long id) {
// this.iDraftMapService.deleteOverlap(id);
// }
/*-------------- 自动折返 ------------------*/

View File

@ -0,0 +1,41 @@
package club.joylink.rtss.controller.draft;
import club.joylink.rtss.services.draftData.DraftMapOverlapService;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/draftMap/{id}/overlap")
@Slf4j
public class DraftMapOverlapController {
@Autowired
private DraftMapOverlapService draftMapOverlapService;
@GetMapping("/paging")
public PageVO<MapOverlapVO> pagingQuery(@PathVariable Long id, MapOverlapQueryVO queryVO) {
return this.draftMapOverlapService.pagingQuery(id, queryVO);
}
@GetMapping("/all")
public List<MapOverlapVO> queryAll(@PathVariable Long id) {
return this.draftMapOverlapService.queryAll(id);
}
@PutMapping("/{code}")
public void update(@PathVariable Long id, @PathVariable String code, @RequestBody MapOverlapVO vo) {
this.draftMapOverlapService.update(id, code, vo);
}
@DeleteMapping("/{code}")
public void delete(@PathVariable Long id, @PathVariable String code) {
this.draftMapOverlapService.delete(id, code);
}
}

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.controller.draft;
import club.joylink.rtss.services.draftData.DraftMapRouteService;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.MapRouteQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapRouteNewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,11 +23,21 @@ public class DraftMapRouteController {
return this.draftMapRouteService.createRailwayRoute(id, routeNewVO);
}
@GetMapping("/paging")
public PageVO<MapRouteNewVO> pagingQuery(@PathVariable Long id, MapRouteQueryVO queryVO) {
return this.draftMapRouteService.pagingQuery(id, queryVO);
}
@GetMapping("/all")
public List<MapRouteNewVO> queryAllRoutes(@PathVariable Long id) {
return this.draftMapRouteService.queryAllRoutes(id);
}
@PutMapping("/{code}")
public void update(@PathVariable Long id, @PathVariable String code, @RequestBody MapRouteNewVO routeNewVO) {
this.draftMapRouteService.update(id, code, routeNewVO);
}
@DeleteMapping("/{code}")
public void delete(@PathVariable Long id, @PathVariable String code) {
this.draftMapRouteService.deleteRoute(id, code);

View File

@ -0,0 +1,36 @@
package club.joylink.rtss.controller.draft;
import club.joylink.rtss.services.draftData.DraftMapSignalApproachSectionService;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapSASQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapSignalApproachSectionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/draftMap/{id}/signalApproachSection")
@Slf4j
public class DraftMapSignalApproachSectionController {
@Autowired
private DraftMapSignalApproachSectionService draftMapSignalApproachSectionService;
@GetMapping("/paging")
public PageVO<MapSignalApproachSectionVO> pagingQuery(@PathVariable Long id, MapSASQueryVO queryVO) {
return this.draftMapSignalApproachSectionService.pagingQuery(id, queryVO);
}
@GetMapping("/all")
public List<MapSignalApproachSectionVO> queryAll(@PathVariable Long id) {
return this.draftMapSignalApproachSectionService.queryAll(id);
}
@PutMapping("/{signalCode}")
public void update(@PathVariable Long id, @PathVariable String signalCode, @RequestBody MapSignalApproachSectionVO vo) {
this.draftMapSignalApproachSectionService.update(id, signalCode, vo);
}
}

View File

@ -865,9 +865,6 @@ public class DraftMapService implements IDraftMapService {
if (StringUtils.hasText(queryVO.getEndSignalCode())) {
criteria.andEndSignalCodeEqualTo(queryVO.getEndSignalCode());
}
if (StringUtils.hasText(queryVO.getNearSectionCode())) {
criteria.andNearSectionCodeEqualTo(queryVO.getNearSectionCode());
}
Page<DraftMapRoute> pageTotal = (Page<DraftMapRoute>) draftMapRouteDAO.selectByExampleWithBLOBs(example);
List<MapRouteVO> routeVOList = pageTotal.getResult().stream().map(MapRouteVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(pageTotal, routeVOList);
@ -936,50 +933,50 @@ public class DraftMapService implements IDraftMapService {
/*------------ Route END ---------------------*/
/*------------overlap start ---------------------*/
@Override
public void createOverlap(MapOverlapVO mapOverlapVO) {
if (StringUtils.hasText(mapOverlapVO.getName())) {
confirmOverlapNameNotRepeat(mapOverlapVO);
}
DraftMapOverlap draftMapOverlap = mapOverlapVO.convert2Draft();
this.draftMapOverlapDAO.insert(draftMapOverlap);
}
@Override
public PageVO<MapOverlapVO> queryPagedOverlap(Long mapId, MapOverlapQueryVO queryVO) {
Objects.requireNonNull(mapId);
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
DraftMapOverlapExample example = new DraftMapOverlapExample();
DraftMapOverlapExample.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId);
if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeEqualTo(queryVO.getCode());
}
Page<DraftMapOverlap> page = (Page<DraftMapOverlap>)
this.draftMapOverlapDAO.selectByExampleWithBLOBs(example);
List<MapOverlapVO> voList = page.getResult().stream().map(MapOverlapVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(page, voList);
}
@Override
public MapOverlapVO getOverlapById(Long id) {
Objects.requireNonNull(id);
DraftMapOverlap draftMapOverlap = getDraftMapOverlapEntity(id);
return MapOverlapVO.convert2VO(draftMapOverlap);
}
@Override
public void updateOverlap(Long id, MapOverlapVO mapOverlapVO) {
getDraftMapOverlapEntity(id);
DraftMapOverlap draftMapOverlap = mapOverlapVO.convert2Draft();
draftMapOverlap.setId(id);
this.draftMapOverlapDAO.updateByPrimaryKeySelective(draftMapOverlap);
}
@Override
public void deleteOverlap(Long id) {
this.draftMapOverlapDAO.deleteByPrimaryKey(id);
}
// @Override
// public void createOverlap(MapOverlapVO mapOverlapVO) {
// if (StringUtils.hasText(mapOverlapVO.getName())) {
// confirmOverlapNameNotRepeat(mapOverlapVO);
// }
// DraftMapOverlap draftMapOverlap = mapOverlapVO.convert2Draft();
// this.draftMapOverlapDAO.insert(draftMapOverlap);
// }
//
// @Override
// public PageVO<MapOverlapVO> queryPagedOverlap(Long mapId, MapOverlapQueryVO queryVO) {
// Objects.requireNonNull(mapId);
// PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
// DraftMapOverlapExample example = new DraftMapOverlapExample();
// DraftMapOverlapExample.Criteria criteria = example.createCriteria();
// criteria.andMapIdEqualTo(mapId);
// if (StringUtils.hasText(queryVO.getCode())) {
// criteria.andCodeEqualTo(queryVO.getCode());
// }
// Page<DraftMapOverlap> page = (Page<DraftMapOverlap>)
// this.draftMapOverlapDAO.selectByExampleWithBLOBs(example);
// List<MapOverlapVO> voList = page.getResult().stream().map(MapOverlapVO::convert2VO).collect(Collectors.toList());
// return PageVO.convert(page, voList);
// }
//
// @Override
// public MapOverlapVO getOverlapById(Long id) {
// Objects.requireNonNull(id);
// DraftMapOverlap draftMapOverlap = getDraftMapOverlapEntity(id);
// return MapOverlapVO.convert2VO(draftMapOverlap);
// }
//
// @Override
// public void updateOverlap(Long id, MapOverlapVO mapOverlapVO) {
// getDraftMapOverlapEntity(id);
// DraftMapOverlap draftMapOverlap = mapOverlapVO.convert2Draft();
// draftMapOverlap.setId(id);
// this.draftMapOverlapDAO.updateByPrimaryKeySelective(draftMapOverlap);
// }
//
// @Override
// public void deleteOverlap(Long id) {
// this.draftMapOverlapDAO.deleteByPrimaryKey(id);
// }
/*------------ Overlap END ---------------------*/

View File

@ -241,15 +241,15 @@ public interface IDraftMapService {
void deleteRoute(Long routeId);
/*------------overlap start ---------------------*/
void createOverlap(MapOverlapVO mapOverlapVO);
PageVO<MapOverlapVO> queryPagedOverlap(Long mapId, MapOverlapQueryVO queryVO);
MapOverlapVO getOverlapById(Long id);
void updateOverlap(Long id, MapOverlapVO mapOverlapVO);
void deleteOverlap(Long id);
//
// void createOverlap(MapOverlapVO mapOverlapVO);
//
// PageVO<MapOverlapVO> queryPagedOverlap(Long mapId, MapOverlapQueryVO queryVO);
//
// MapOverlapVO getOverlapById(Long id);
//
// void updateOverlap(Long id, MapOverlapVO mapOverlapVO);
// void deleteOverlap(Long id);
/*------------autoReentry start ---------------------*/

View File

@ -79,23 +79,23 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
if (!CollectionUtils.isEmpty(draftMapOverlapList)) {
for (DraftMapOverlap overlap : draftMapOverlapList) {
// 丢失道岔处理
MapOverlapVO mapOverlapVO = MapOverlapVO.convertRel2VO(overlap);
List<MapOverlapRelSectionSwitchVO> list = mapOverlapVO.getRelSectionSwitchList();
for (MapOverlapRelSectionSwitchVO vo : list) {
if (!CollectionUtils.isEmpty(vo.getRouteOverlapSwitchList())) {
List<MapCISwitchVO> removeList = new ArrayList<>();
for (MapCISwitchVO mapCISwitchVO : vo.getRouteOverlapSwitchList()) {
if (Objects.isNull(switchMap.get(mapCISwitchVO.getSwitchCode()))) {
removeList.add(mapCISwitchVO);
}
}
if (!CollectionUtils.isEmpty(removeList)) {
vo.getRouteOverlapSwitchList().removeAll(removeList);
overlap.setRelData(mapOverlapVO.convert2Draft().getRelData());
this.draftMapOverlapDAO.updateByPrimaryKeyWithBLOBs(overlap);
}
}
}
// MapOverlapVO mapOverlapVO = MapOverlapVO.convertRel2VO(overlap);
// List<MapOverlapRelSectionSwitchVO> list = mapOverlapVO.getRelSectionSwitchList();
// for (MapOverlapRelSectionSwitchVO vo : list) {
// if (!CollectionUtils.isEmpty(vo.getRouteOverlapSwitchList())) {
// List<MapCISwitchVO> removeList = new ArrayList<>();
// for (MapCISwitchVO mapCISwitchVO : vo.getRouteOverlapSwitchList()) {
// if (Objects.isNull(switchMap.get(mapCISwitchVO.getSwitchCode()))) {
// removeList.add(mapCISwitchVO);
// }
// }
// if (!CollectionUtils.isEmpty(removeList)) {
// vo.getRouteOverlapSwitchList().removeAll(removeList);
// overlap.setRelData(mapOverlapVO.convert2Draft().getRelData());
// this.draftMapOverlapDAO.updateByPrimaryKeyWithBLOBs(overlap);
// }
// }
// }
}
}
}

View File

@ -0,0 +1,17 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapVO;
import java.util.List;
public interface DraftMapOverlapService {
PageVO<MapOverlapVO> pagingQuery(Long id, MapOverlapQueryVO queryVO);
List<MapOverlapVO> queryAll(Long id);
void update(Long id, String code, MapOverlapVO vo);
void delete(Long id, String code);
}

View File

@ -0,0 +1,79 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.dao.DraftMapOverlapDAO;
import club.joylink.rtss.entity.DraftMapOverlap;
import club.joylink.rtss.entity.DraftMapOverlapExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapOverlapVO;
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.util.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class DraftMapOverlapServiceImpl implements DraftMapOverlapService {
@Autowired
private DraftMapOverlapDAO draftMapOverlapDAO;
@Override
public PageVO<MapOverlapVO> pagingQuery(Long id, MapOverlapQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
DraftMapOverlapExample example = new DraftMapOverlapExample();
DraftMapOverlapExample.Criteria criteria = example.createCriteria()
.andMapIdEqualTo(id);
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
Page<DraftMapOverlap> mapOverlaps = (Page<DraftMapOverlap>) this.draftMapOverlapDAO.selectByExampleWithBLOBs(example);
List<MapOverlapVO> voList = mapOverlaps.getResult().stream()
.map(MapOverlapVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(mapOverlaps, voList);
}
@Override
public List<MapOverlapVO> queryAll(Long id) {
DraftMapOverlapExample example = new DraftMapOverlapExample();
example.createCriteria()
.andMapIdEqualTo(id);
List<DraftMapOverlap> overlapList = this.draftMapOverlapDAO.selectByExampleWithBLOBs(example);
return overlapList.stream()
.map(MapOverlapVO::convert2VO)
.collect(Collectors.toList());
}
@Override
public void update(Long id, String code, MapOverlapVO vo) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(vo.getName());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(vo.getPathList());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(vo.getUnlockTime());
DraftMapOverlapExample example = new DraftMapOverlapExample();
example.createCriteria()
.andMapIdEqualTo(id)
.andCodeEqualTo(code);
List<DraftMapOverlap> draftMapOverlaps = this.draftMapOverlapDAO.selectByExampleWithBLOBs(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(draftMapOverlaps);
MapOverlapVO update = MapOverlapVO.convert2VO(draftMapOverlaps.get(0));
update.setName(vo.getName());
update.setUnlockTime(vo.getUnlockTime());
update.setPathList(vo.getPathList());
DraftMapOverlap db = update.convert2Draft();
this.draftMapOverlapDAO.updateByPrimaryKeyWithBLOBs(db);
}
@Override
public void delete(Long id, String code) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(code);
DraftMapOverlapExample example = new DraftMapOverlapExample();
example.createCriteria()
.andMapIdEqualTo(id)
.andCodeEqualTo(code);
this.draftMapOverlapDAO.deleteByExample(example);
}
}

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.MapRouteQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapRouteNewVO;
import java.util.List;
@ -7,7 +9,11 @@ import java.util.List;
public interface DraftMapRouteService {
MapRouteNewVO createRailwayRoute(Long id, MapRouteNewVO routeNewVO);
PageVO<MapRouteNewVO> pagingQuery(Long id, MapRouteQueryVO queryVO);
List<MapRouteNewVO> queryAllRoutes(Long id);
void update(Long id, String routeCode, MapRouteNewVO routeNewVO);
void deleteRoute(Long id, String code);
}

View File

@ -7,12 +7,17 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IDraftMapService;
import club.joylink.rtss.simulation.rt.repo.CommonRepository;
import club.joylink.rtss.simulation.rt.repo.CommonRepositoryBuilder;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.MapRouteQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapGraphDataNewVO;
import club.joylink.rtss.vo.client.map.newmap.MapRouteNewVO;
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 java.util.ArrayList;
import java.util.List;
@ -62,6 +67,34 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
return routeNewVO;
}
@Override
public PageVO<MapRouteNewVO> pagingQuery(Long id, MapRouteQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
DraftMapRouteExample example = new DraftMapRouteExample();
DraftMapRouteExample.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(id);
if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeEqualTo(queryVO.getCode());
}
if (StringUtils.hasText(queryVO.getName())) {
queryVO.setName(String.format("%%%s%%", queryVO.getName()));
criteria.andNameLike(queryVO.getName());
}
if (StringUtils.hasText(queryVO.getStationCode())) {
criteria.andStationCodeEqualTo(queryVO.getStationCode());
}
if (StringUtils.hasText(queryVO.getStartSignalCode())) {
criteria.andStartSignalCodeEqualTo(queryVO.getStartSignalCode());
}
if (StringUtils.hasText(queryVO.getEndSignalCode())) {
criteria.andEndSignalCodeEqualTo(queryVO.getEndSignalCode());
}
Page<DraftMapRoute> pageTotal = (Page<DraftMapRoute>) draftMapRouteDAO.selectByExampleWithBLOBs(example);
List<MapRouteNewVO> routeVOList = pageTotal.getResult().stream()
.map(MapRouteNewVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(pageTotal, routeVOList);
}
@Override
public List<MapRouteNewVO> queryAllRoutes(Long id) {
DraftMapRouteExample example = new DraftMapRouteExample();
@ -71,6 +104,25 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
return MapRouteNewVO.convertDraft2VOList(routeList);
}
@Override
public void update(Long id, String routeCode, MapRouteNewVO routeNewVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(routeNewVO.getName());
DraftMapRouteExample example = new DraftMapRouteExample();
example.createCriteria()
.andMapIdEqualTo(id)
.andCodeEqualTo(routeCode);
List<DraftMapRoute> draftMapRoutes = this.draftMapRouteDAO.selectByExampleWithBLOBs(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(draftMapRoutes);
DraftMapRoute draftMapRoute = draftMapRoutes.get(0);
MapRouteNewVO update = MapRouteNewVO.convert2VO(draftMapRoute);
update.setFlt(routeNewVO.isFlt());
update.setArc(routeNewVO.isArc());
update.setArs(routeNewVO.isArs());
update.setName(routeNewVO.getName());
DraftMapRoute db = update.convert2Draft();
this.draftMapRouteDAO.updateByPrimaryKeyWithBLOBs(db);
}
@Transactional
@Override
public void deleteRoute(Long id, String code) {

View File

@ -0,0 +1,16 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapSASQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapSignalApproachSectionVO;
import java.util.List;
public interface DraftMapSignalApproachSectionService {
PageVO<MapSignalApproachSectionVO> pagingQuery(Long id, MapSASQueryVO queryVO);
List<MapSignalApproachSectionVO> queryAll(Long id);
void update(Long id, String signalCode, MapSignalApproachSectionVO vo);
}

View File

@ -0,0 +1,67 @@
package club.joylink.rtss.services.draftData;
import club.joylink.rtss.dao.DraftMapSignalApproachSectionDAO;
import club.joylink.rtss.entity.DraftMapSignalApproachSection;
import club.joylink.rtss.entity.DraftMapSignalApproachSectionExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.map.newmap.MapSASQueryVO;
import club.joylink.rtss.vo.client.map.newmap.MapSignalApproachSectionVO;
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.util.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class DraftMapSignalApproachSectionServiceImpl implements DraftMapSignalApproachSectionService {
@Autowired
private DraftMapSignalApproachSectionDAO draftMapSignalApproachSectionDAO;
@Override
public PageVO<MapSignalApproachSectionVO> pagingQuery(Long id, MapSASQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
DraftMapSignalApproachSectionExample example = new DraftMapSignalApproachSectionExample();
DraftMapSignalApproachSectionExample.Criteria criteria = example.createCriteria()
.andMapIdEqualTo(id);
if (StringUtils.hasText(queryVO.getSignalCode())) {
criteria.andSignalCodeEqualTo(queryVO.getSignalCode());
}
Page<DraftMapSignalApproachSection> mapOverlaps = (Page<DraftMapSignalApproachSection>) this.draftMapSignalApproachSectionDAO.selectByExampleWithBLOBs(example);
List<MapSignalApproachSectionVO> voList = mapOverlaps.getResult().stream()
.map(MapSignalApproachSectionVO::convert2VO)
.collect(Collectors.toList());
return PageVO.convert(mapOverlaps, voList);
}
@Override
public List<MapSignalApproachSectionVO> queryAll(Long id) {
DraftMapSignalApproachSectionExample example = new DraftMapSignalApproachSectionExample();
DraftMapSignalApproachSectionExample.Criteria criteria = example.createCriteria()
.andMapIdEqualTo(id);
Page<DraftMapSignalApproachSection> mapOverlaps = (Page<DraftMapSignalApproachSection>) this.draftMapSignalApproachSectionDAO.selectByExampleWithBLOBs(example);
return mapOverlaps.getResult().stream()
.map(MapSignalApproachSectionVO::convert2VO)
.collect(Collectors.toList());
}
@Override
public void update(Long id, String signalCode, MapSignalApproachSectionVO vo) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(vo.getReleaseTime());
DraftMapSignalApproachSectionExample example = new DraftMapSignalApproachSectionExample();
example.createCriteria()
.andMapIdEqualTo(id)
.andSignalCodeEqualTo(signalCode);
List<DraftMapSignalApproachSection> approachSections = this.draftMapSignalApproachSectionDAO.selectByExampleWithBLOBs(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(approachSections);
MapSignalApproachSectionVO update = MapSignalApproachSectionVO.convert2VO(approachSections.get(0));
update.setReleaseTime(vo.getReleaseTime());
update.setSectionPathList(vo.getSectionPathList());
DraftMapSignalApproachSection db = update.convert2Draft();
this.draftMapSignalApproachSectionDAO.updateByPrimaryKeyWithBLOBs(db);
}
}

View File

@ -18,7 +18,8 @@ import java.util.Set;
@Slf4j
@Component
public class SrdLogicService {
public static final int TRAIN_RUN_RATE = 20; // 列车运行逻辑频率
// public static final int TRAIN_RUN_RATE = 20; // 列车运行逻辑频率
public static final int TRAIN_RUN_RATE = 1000; // 列车运行逻辑频率
public static final int DEVICE_RUN_RATE = 500; // 其他设备逻辑频率
public void buildRepository(RtSimulation rtSimulation, MapVO mapVO) {
@ -81,19 +82,24 @@ public class SrdLogicService {
public void srTrainRun(SrdRepository repository) {
List<SrTrain> trainList = repository.getTrainList();
for (SrTrain srTrain : trainList) {
if (!srTrain.isUsing()) {
continue;
}
// 计算列车加速度更新列车速度计算列车运行距离更新列车位置
boolean right = srTrain.isRight();
TrackPosition position = srTrain.getHeadPosition();
int cv = this.calculateSpeed(srTrain);
float cv = this.calculateSpeed(srTrain);
int s = this.calculateLen(srTrain, cv, TRAIN_RUN_RATE);
if (s == 0) {
continue;
}
TrackPosition np = calculatePosition(position, s, right, new HashSet<>());
if (np.equals(position) && cv != 0) {
cv = 0;
}
Set<SrTrack> occupiedTrackSet = new HashSet<>();
if (srTrain.getId().equals("001")) {
System.out.println(cv);
System.out.println(s);
System.out.println(np.debugStr());
}
TrackPosition tailPosition = this.calculatePosition(np, srTrain.getLen(), !right, occupiedTrackSet);
srTrain.updatePositionAndSpeed(np, tailPosition, cv);
// 更新计轴占用
@ -110,28 +116,36 @@ public class SrdLogicService {
}
}
private int calculateLen(SrTrain srTrain, int cv, int time) {
int s = cv * time;
/**
*
* @param srTrain
* @param cv 速度单位mm/ms
* @param time 时间单位ms
* @return
*/
private int calculateLen(SrTrain srTrain, float cv, int time) {
int s = (int) (cv * time); // 距离单位mm
if (!srTrain.isNeutralGear()) {
return s * srTrain.getGear();
}
return s;
}
private int calculateSpeed(SrTrain srTrain) {
long speed = srTrain.getSpeed();
int wa = (int) (10 + speed * 0.001 + speed * speed * 0.0000003); // 阻力所产生的反向加速度
int pa = 0;
private float calculateSpeed(SrTrain srTrain) {
float speed = srTrain.getSpeed();
float wa = (0.01f + speed / 1000 + speed * speed * 0.0003f); // 阻力所产生的反向加速度
float pa = 0;
if (srTrain.isEb()) {
pa = SrTrain.ES_DEC;
pa = srTrain.ES_DEC;
} else {
pa = srTrain.getP() >= 0 ? srTrain.getP() * SrTrain.MAX_ACC : srTrain.getP() * SrTrain.MAX_DEC;
pa = srTrain.getP() >= 0 ? srTrain.getP() * srTrain.MAX_ACC / 100 : srTrain.getP() * srTrain.MAX_DEC / 100;
pa *= srTrain.getGear();
}
int a = pa - wa;
int cv = (int) (speed + a * TRAIN_RUN_RATE); // 当前速度
float a = pa - wa;
float cv = (speed + a * TRAIN_RUN_RATE / 1000); // 当前速度
if (cv < 0) {
cv = 0;
}
if (srTrain.isNeutralGear() && cv > 0) { // 空档位
cv = 0;
}
return cv;
}

View File

@ -0,0 +1,20 @@
package club.joylink.rtss.simulation.rt.SRD;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.bo.SrTrack;
import club.joylink.rtss.simulation.rt.SRD.bo.SrTrain;
import club.joylink.rtss.simulation.rt.SRD.bo.SrdRepository;
import club.joylink.rtss.simulation.rt.SRD.bo.TrackPosition;
import org.springframework.stereotype.Component;
@Component
public class SrdTrainService {
public void loadTrain(RtSimulation simulation, String trainId, boolean right, String trackId) {
SrdRepository srdRepository = simulation.getRepository(SrdRepository.NAME, SrdRepository.class);
SrTrain train = srdRepository.getTrainById(trainId);
SrTrack track = srdRepository.getTrackById(trackId);
TrackPosition trackPosition = new TrackPosition(track, 5000);
train.initPosition(trackPosition, right);
train.updatePositionAndSpeed(trackPosition, null, 5);
}
}

View File

@ -63,10 +63,6 @@ public class SrTrack extends SrDevice implements Debug {
this.rightFlankTrack = rightFlank;
}
void setSrSwitch(SrSwitch srSwitch) {
this.srSwitch = srSwitch;
}
public SrTrack queryNextTrack(boolean right) {
if (this.srSwitch != null) {
if (this.srSwitch.isNormalPosition()) {

View File

@ -7,10 +7,6 @@ import lombok.Getter;
*/
@Getter
public class SrTrain extends SrDevice {
/**
* 是否使用中
*/
boolean using;
/**
* 列车长度,单位mm
@ -21,19 +17,19 @@ public class SrTrain extends SrDevice {
*/
int mass = 224;
/**
* 最大加速度, 单位mm/s2
* 最大加速度, 单位m/s2
*/
public static final int MAX_ACC = 1600;
public float MAX_ACC = 1.6f;
/**
* 最大常用制动加速度, 单位mm/s2
* 最大常用制动加速度, 单位m/s2
*/
public static final int MAX_DEC = -1200;
public float MAX_DEC = -1.2f;
/**
* 紧急制动加速度, 单位mm/s2
* 紧急制动加速度, 单位m/s2
*/
public static final int ES_DEC = -1500;
public float ES_DEC = -1.5f;
/**
* 功率-100 <= p <= 100
* 功率-100 <= p <= 100 (%)
*/
int p;
/**
@ -41,9 +37,9 @@ public class SrTrain extends SrDevice {
*/
boolean eb;
/**
* 列车速度,单位mm/s
* 列车速度,单位m/s
*/
int speed;
float speed;
/**
* 列车方向
*/
@ -73,19 +69,27 @@ public class SrTrain extends SrDevice {
return NEUTRAL == this.gear;
}
public void updatePositionAndSpeed(TrackPosition headPosition, TrackPosition tailPosition, int v) {
public void updatePositionAndSpeed(TrackPosition headPosition, TrackPosition tailPosition, float v) {
this.headPosition = headPosition;
this.tailPosition = tailPosition;
this.speed = v;
}
@Override
public void initState() {
this.p = 0;
this.eb = false;
this.speed = 0;
this.gear = NEUTRAL;
this.headPosition = null;
}
@Override
public void applyState(int state) {
}
public void initPosition(TrackPosition trackPosition, boolean right) {
this.headPosition = trackPosition;
this.right = right;
}
}

View File

@ -58,6 +58,9 @@ public class SrdRepository extends SimulationRepository {
for (SrSwitch srSwitch : this.switchMap.values()) {
srSwitch.initState();
}
for (SrTrain train : this.trainMap.values()) {
train.initState();
}
}
public List<SrAXC> getAxcList() {
@ -93,4 +96,16 @@ public class SrdRepository extends SimulationRepository {
CommonSection commonSection = commonRepository.getSectionById(sectionId);
return this.getAxcById(commonSection.getAxc().getId());
}
public SrTrain getTrainById(String id) {
SrTrain srTrain = this.trainMap.get(id);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(srTrain);
return srTrain;
}
public SrTrack getTrackById(String id) {
SrTrack srTrack = this.trackMap.get(id);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(srTrack);
return srTrack;
}
}

View File

@ -95,6 +95,20 @@ public class SrdRepositoryBuilder {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(c,
String.format("道岔[%s]关联区段C[%s]不存在", switchVO.getCode(), switchVO.getSectionCCode()));
SrSwitch turnout = turnoutMap.get(switchVO.getCode());
a.srSwitch = turnout;
b.srSwitch = turnout;
c.srSwitch = turnout;
if (a.leftTrack != null) {
a.rightTrack = b;
b.leftTrack = a;
a.rightFlankTrack = c;
c.leftTrack = a;
} else if (a.rightTrack != null) {
a.leftTrack = b;
b.rightTrack = a;
a.leftFlankTrack = c;
c.rightTrack = a;
}
}
}
@ -105,18 +119,19 @@ public class SrdRepositoryBuilder {
if (Objects.equals(sectionVO.getType(), "02")) { // 逻辑区段
continue;
}
if (Objects.equals(sectionVO.getType(), "01") || Objects.equals(sectionVO.getType(), "03")) {
// 创建轨道
SrTrack srTrack = new SrTrack(sectionVO.getCode());
trackMap.put(srTrack.getId(), srTrack);
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(sectionVO.getLengthFact() > 0,
// String.format("区段[%s(%s)]未设置实际长度或长度小于等于0", sectionVO.getName(), sectionVO.getCode()));
srTrack.name = sectionVO.getName();
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(sectionVO.getLengthFact() > 0,
String.format("区段[%s(%s)]未设置实际长度或长度小于等于0", sectionVO.getName(), sectionVO.getCode()));
srTrack.len = ((int) (sectionVO.getLengthFact() * 1000));
}
if (Objects.equals(sectionVO.getType(), "04") || Objects.equals(sectionVO.getType(), "01")) { // 道岔计轴
// 创建计轴器
SrAXC srAXC = new SrAXC(sectionVO.getCode());
axcMap.put(srAXC.getId(), srAXC);
continue;
}
}
}

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.simulation.rt.SRD.bo;
public class TrackPosition {
import club.joylink.rtss.simulation.Debug;
public class TrackPosition implements Debug {
SrTrack track;
/**
* 轨道偏移量单位mm
@ -19,4 +21,9 @@ public class TrackPosition {
public int getOffset() {
return offset;
}
@Override
public String debugStr() {
return String.format("[%s:%s]", this.track.getName(), this.offset);
}
}

View File

@ -1,8 +1,5 @@
package club.joylink.rtss.simulation.rt.operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.operation.SimulationOperationController;
import club.joylink.rtss.simulation.operation.SimulationOperationMapping;
import club.joylink.rtss.simulation.rt.CIL.CilApiService;

View File

@ -1,17 +1,11 @@
package club.joylink.rtss.simulation.rt.operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.operation.SimulationOperationController;
import club.joylink.rtss.simulation.operation.SimulationOperationMapping;
import club.joylink.rtss.simulation.rt.CIL.CilApiService;
import club.joylink.rtss.simulation.rt.RtSimulation;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Objects;
@SimulationOperationController()
public class SignalOperationHandler {
@Autowired

View File

@ -0,0 +1,24 @@
package club.joylink.rtss.simulation.rt.operation;
import club.joylink.rtss.simulation.operation.SimulationOperationController;
import club.joylink.rtss.simulation.operation.SimulationOperationMapping;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.SrdTrainService;
import org.springframework.beans.factory.annotation.Autowired;
@SimulationOperationController()
public class SrTrainOperationHandler {
@Autowired
private SrdTrainService srdTrainService;
@SimulationOperationMapping("Train_Load_Spare_Train")
public void loadTrain(RtSimulation simulation, String groupNumber,
boolean right, String sectionCode) {
this.srdTrainService.loadTrain(simulation, groupNumber, right, sectionCode);
}
@SimulationOperationMapping("Train_Drive_Speed_Control")
public void powerControl(RtSimulation simulation, String groupNumber, int p) {
}
}

View File

@ -1,18 +1,11 @@
package club.joylink.rtss.simulation.rt.operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.operation.SimulationOperationController;
import club.joylink.rtss.simulation.operation.SimulationOperationMapping;
import club.joylink.rtss.simulation.rt.CIL.CilApiService;
import club.joylink.rtss.simulation.rt.RtSimulation;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Objects;
@SimulationOperationController()
public class SwitchOperationHandler {
@Autowired

View File

@ -26,7 +26,4 @@ public class MapRouteQueryVO extends PageQueryVO {
@ApiModelProperty(value="终端信号机")
private String endSignalCode;
@ApiModelProperty(value="接近区段")
private String nearSectionCode;
}

View File

@ -11,6 +11,6 @@ import lombok.Setter;
@Setter
public class MapOverlapQueryVO extends PageQueryVO {
@ApiModelProperty(value="延续保护唯一编号")
private String code;
@ApiModelProperty(value="延续保护名称")
private String name;
}

View File

@ -13,9 +13,7 @@ import lombok.Setter;
import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
@ -70,17 +68,11 @@ public class MapOverlapVO {
private List<MapSectionPathVO> triggerPathList;
/**
* 延续保护线路列表
*/
@NotEmpty(message="延续保护线路列表至少有一条")
private List<MapOverlapRelSectionSwitchVO> relSectionSwitchList;
@ApiModelProperty(value = "延续保护路径列表")
private List<MapSectionPathVO> pathList;
public MapOverlapVO() {
relSectionSwitchList = new ArrayList<>();
}
public static MapOverlapVO convert2VO(DraftMapOverlap draftMapOverlap) {
@ -114,7 +106,7 @@ public class MapOverlapVO {
draftMapOverlap.setId(getId());
draftMapOverlap.setCode(getCode());
draftMapOverlap.setMapId(getMapId());
// draftMapOverlap.setName(getName());
draftMapOverlap.setName(getName());
// relData中不包含id和mapId
draftMapOverlap.setRelData(getJsonData());
return draftMapOverlap;

View File

@ -15,7 +15,9 @@ import org.springframework.util.CollectionUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ApiModel
@ -135,10 +137,6 @@ public class MapRouteNewVO {
*/
private boolean flt;
/** 是否先锁闭——办理过程直接先锁闭区段 */
@ApiModelProperty(value = "是否先锁闭——办理过程直接先锁闭区段")
private boolean lockFirst;
/**
* 延时解锁时间单位秒s
*/

View File

@ -0,0 +1,13 @@
package club.joylink.rtss.vo.client.map.newmap;
import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class MapSASQueryVO extends PageQueryVO {
private String signalCode;
}

View File

@ -1,11 +1,11 @@
package club.joylink.rtss.vo.client.map.newmap;
import club.joylink.rtss.entity.DraftMapSignalApproachSection;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.entity.DraftMapSignalApproachSection;
import club.joylink.rtss.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@ -33,9 +33,6 @@ public class MapSignalApproachSectionVO {
@NotNull(message = "地图id不能为空")
private Long mapId;
// @NotBlank(message = "接近区段编号不能为空")
// private String code;
/**
* 始端信号机 编号
*/
@ -43,21 +40,14 @@ public class MapSignalApproachSectionVO {
@ApiModelProperty(value="始端信号机", required=true)
private String signalCode;
@ApiModelProperty(value="接近区段CBTC模式数据列表")
private List<String> routeSectionList;
@ApiModelProperty(value = "接近区段(后备模式)列表")
private List<String> blockSectionList;
@ApiModelProperty(value = "是否引导信号机")
private Boolean callOn;
/**
* 接近锁闭解锁时间
*/
private Integer releaseTime;
private List<MapSectionPathVO> sectionPathList;
public MapSignalApproachSectionVO() {
this.routeSectionList = new ArrayList<>();
}
public static MapSignalApproachSectionVO convert2VO(DraftMapSignalApproachSection approachSection) {
@ -88,7 +78,6 @@ public class MapSignalApproachSectionVO {
DraftMapSignalApproachSection approachSection = new DraftMapSignalApproachSection();
approachSection.setId(this.getId());
approachSection.setMapId(this.getMapId());
// approachSection.setCode(this.getCode());
approachSection.setSignalCode(this.getSignalCode());
approachSection.setRelData(this.getJsonData());
return approachSection;