Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1
This commit is contained in:
commit
c68142f798
2
sql/20220914-zhouyin.sql
Normal file
2
sql/20220914-zhouyin.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- 武汉8号线添加第三方账号
|
||||
INSERT INTO `joylink`.`sys_account` ( `account`, `parent_account`, `type`, `org_id`, `name`, `nickname`, `avatar_path`, `password`, `mobile`, `nationcode`, `email`, `wx_id`, `wx_union_id`, `wm_open_id`, `status`, `roles`, `source`, `create_time`, `update_user_id`, `update_time`) VALUES ('yjddzh_train_place', NULL, '2', NULL, NULL, '武汉8号线_train_place', NULL, 'train_place', 'train_place', NULL, 'yjddzh@tests.com', NULL, NULL, NULL, '1', '01', NULL, '2022-09-14 10:00:14', NULL, NULL);
|
@ -13,7 +13,7 @@ public enum MapPrdTypeEnum {
|
||||
BIG_SCREEN("07", "大屏工作站", null),
|
||||
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
|
||||
DEPOT_IL("09", "车辆段联锁工作站", null),
|
||||
BIG_SCREEN_TRAIN_POSITION("10", "大屏车辆真实工作站", null),
|
||||
YJDDZH("10", "应急调度指挥系统", null),
|
||||
// CTC("10", "CTC工作站")
|
||||
;
|
||||
|
||||
|
@ -61,7 +61,9 @@ public enum Project {
|
||||
/** 哈盈达-铁路 */
|
||||
HYD_RAILWAY,
|
||||
/** 武汉8号线 */
|
||||
WH
|
||||
// WH,
|
||||
/** 武汉8号线 应急调度指挥系统*/
|
||||
YJDDZH
|
||||
;
|
||||
|
||||
public static boolean isDefault(Project project) {
|
||||
|
@ -67,6 +67,9 @@ public enum ProjectDeviceType {
|
||||
SANDBOX,
|
||||
/** 派班工作站 */
|
||||
SCHEDULING,
|
||||
|
||||
PIS_STAND,
|
||||
PIS_TRAIN,
|
||||
/* -----------client device end---------- */
|
||||
;
|
||||
|
||||
|
@ -4,9 +4,9 @@ import club.joylink.rtss.services.draftData.DraftMapDataHandleService;
|
||||
import club.joylink.rtss.services.publishData.PublishMapDataHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* 地图数据处理
|
||||
@ -35,4 +35,12 @@ public class MapDataHandleController {
|
||||
public void signalShowDirection() {
|
||||
this.publishMapDataHandler.signalShowDirection();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改线路数据和ISCS的车站名
|
||||
*/
|
||||
@PutMapping("/{mapId}/stationName/mapAndIscs")
|
||||
public void changeStationName(@PathVariable long mapId, @RequestBody LinkedHashMap<String, String> nameMap) {
|
||||
this.publishMapDataHandler.changeStationName(mapId, nameMap);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,18 @@ public class AudioResourcesController {
|
||||
* 创建
|
||||
*/
|
||||
@PostMapping()
|
||||
public void create(@RequestBody @Validated AudioResourcesVO vo) {
|
||||
public void create(@RequestBody @Validated(value = AudioResourcesVO.Create.class) AudioResourcesVO vo) {
|
||||
audioResourcesService.create(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成资源
|
||||
*/
|
||||
@PostMapping("/generate")
|
||||
public void generate(@RequestBody @Validated(value = AudioResourcesVO.Generate.class) AudioResourcesVO vo) {
|
||||
audioResourcesService.generate(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
|
@ -0,0 +1,120 @@
|
||||
package club.joylink.rtss.controller.competition.question;
|
||||
|
||||
|
||||
import club.joylink.rtss.constants.Project;
|
||||
import club.joylink.rtss.services.completition.question.IQuestionBankService;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.competition.TheoryQuestionCountVO;
|
||||
import club.joylink.rtss.vo.client.question.QuestionOptionVO;
|
||||
import club.joylink.rtss.vo.client.question.QuestionQueryVO;
|
||||
import club.joylink.rtss.vo.client.question.QuestionVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*题库管理接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(path = "/api/questionBank2")
|
||||
public class QuestionBankController2 {
|
||||
|
||||
@Autowired
|
||||
private IQuestionBankService iQuestionBankService;
|
||||
|
||||
/**
|
||||
*分页查询题目
|
||||
*/
|
||||
@GetMapping(path = "/questions/paging")
|
||||
public PageVO<QuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
|
||||
queryVO.setProjectCode(loginInfo.getProject().name());
|
||||
return iQuestionBankService.pagingQueryQuestions(queryVO);
|
||||
}
|
||||
|
||||
/**
|
||||
*查询题目列表
|
||||
*/
|
||||
@GetMapping(path = "/questions")
|
||||
public List<QuestionVO> queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo,QuestionQueryVO queryVO) {
|
||||
queryVO.setProjectCode(loginInfo.getProject().name());
|
||||
return iQuestionBankService.queryQuestions(queryVO);
|
||||
}
|
||||
|
||||
/**
|
||||
*获取题目信息
|
||||
*/
|
||||
@GetMapping(path = "/questions/{questionId}")
|
||||
public QuestionVO getQuestion(@PathVariable Long questionId) {
|
||||
return iQuestionBankService.getQuestion(questionId);
|
||||
}
|
||||
|
||||
/**
|
||||
*添加题目
|
||||
*/
|
||||
@PostMapping(path = "/questions")
|
||||
public void addQuestion(@Validated @RequestBody QuestionVO questionVO,@RequestAttribute LoginUserInfoVO loginInfo,
|
||||
@RequestAttribute AccountVO user) {
|
||||
questionVO.setProjectCode(loginInfo.getProject().name());
|
||||
iQuestionBankService.addQuestion(questionVO, user);
|
||||
}
|
||||
|
||||
/**
|
||||
*导入项目或单位试题库
|
||||
*/
|
||||
@PostMapping(path = "/questions/import")
|
||||
public void importProjectQuestion(@Validated @RequestBody List<QuestionVO> questions, @RequestAttribute LoginUserInfoVO loginInfo,
|
||||
@RequestAttribute AccountVO user, @RequestParam(required = false, name = "id") Long companyId) {
|
||||
|
||||
iQuestionBankService.importProjectQuestion(questions, loginInfo.getProject().name(), companyId,user);
|
||||
}
|
||||
|
||||
/**
|
||||
*更新题目
|
||||
*/
|
||||
@PutMapping(path = "/questions/{questionId}")
|
||||
public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo,@RequestBody QuestionVO questionVO) {
|
||||
questionVO.setProjectCode(loginInfo.getProject().name());
|
||||
iQuestionBankService.updateQuestion(questionId, questionVO);
|
||||
}
|
||||
|
||||
/**
|
||||
*删除题目
|
||||
*/
|
||||
@DeleteMapping(path = "/questions/{questionId}")
|
||||
public void deleteQuestion(@PathVariable Long questionId) {
|
||||
iQuestionBankService.deleteQuestion(questionId);
|
||||
}
|
||||
|
||||
/**
|
||||
*根据题目查询选项
|
||||
*/
|
||||
@GetMapping(path = "/questions/{questionId}/options")
|
||||
public List<QuestionOptionVO> getOptionsByQuestionId(@PathVariable Long questionId) {
|
||||
return iQuestionBankService.getOptionsByQuestionId(questionId);
|
||||
}
|
||||
|
||||
/**
|
||||
*根据题型获取题目数量
|
||||
*/
|
||||
@GetMapping(path = "/number")
|
||||
public Integer getNumberUnderKnowledgeAndType(@RequestAttribute LoginUserInfoVO loginInfo, String type, Long companyId) {
|
||||
|
||||
return iQuestionBankService.getNumberWithType(type, loginInfo.getProject().name(), companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
*获取题型数量
|
||||
*/
|
||||
@GetMapping(path = "/type/number")
|
||||
public List<TheoryQuestionCountVO> getNumberUnderKnowledgeAndType(@RequestAttribute LoginUserInfoVO loginInfo, @RequestParam(required = false) Long companyId) {
|
||||
|
||||
String projectCode = Project.isDefault(loginInfo.getProject()) ? null : loginInfo.getProject().name();
|
||||
return iQuestionBankService.countNumByType(projectCode, companyId);
|
||||
}
|
||||
|
||||
}
|
@ -34,6 +34,11 @@ public class IscsSystemResourcesController {
|
||||
iscsSystemResourcesService.batchCreate(vos);
|
||||
}
|
||||
|
||||
@PostMapping("/generate/{mapId}/{type}")
|
||||
public void generate(@PathVariable long mapId, @PathVariable int type) {
|
||||
iscsSystemResourcesService.generate(mapId, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有
|
||||
*/
|
||||
|
@ -4,13 +4,8 @@ import club.joylink.rtss.services.ISysUserService;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.UserQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.user.MobileInfoVO;
|
||||
import club.joylink.rtss.vo.client.user.UpdateEmailVO;
|
||||
import club.joylink.rtss.vo.client.user.UpdateMobileVO;
|
||||
import club.joylink.rtss.vo.client.user.UpdatePasswordVO;
|
||||
import club.joylink.rtss.vo.client.user.*;
|
||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||
import club.joylink.rtss.vo.client.user.AccountRegisterQueryVO;
|
||||
import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
|
||||
import club.joylink.rtss.vo.user.UserRegisterCheck;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -146,4 +141,20 @@ public class UserInfoController {
|
||||
queryVO.setSource(source);
|
||||
return this.iSysUserService.queryPagedUser(queryVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管重置用户密码
|
||||
*/
|
||||
@PutMapping("/{id}/reset/pwd")
|
||||
public void resetPwd(@PathVariable long id) {
|
||||
iSysUserService.resetPwd(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找回密码
|
||||
*/
|
||||
@PutMapping("/retrieve/pwd")
|
||||
public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) {
|
||||
iSysUserService.retrievePwd(vo);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.user.*;
|
||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||
import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
|
||||
import club.joylink.rtss.vo.wx.WmUserSession;
|
||||
import lombok.NonNull;
|
||||
|
||||
@ -325,4 +324,8 @@ public interface ISysUserService {
|
||||
boolean isThirdParentAccountExist(String parentAccount);
|
||||
|
||||
List<SysAccount> findEntitiesBySource(String source);
|
||||
|
||||
void resetPwd(long id);
|
||||
|
||||
void retrievePwd(RetrievePwdVO vo);
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ public class SysUserService implements ISysUserService {
|
||||
|
||||
@Override
|
||||
public String sendMobileValidCode(MobileInfoVO mobileInfoVO) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate(), "发送验证码请求未通过");
|
||||
String code = RandomGenerator.getByLen(4);
|
||||
long ts = System.currentTimeMillis();
|
||||
List<String> params = new ArrayList<>();
|
||||
@ -757,17 +757,43 @@ public class SysUserService implements ISysUserService {
|
||||
public void updatePassword(Long id, UpdatePasswordVO updatePasswordVO) {
|
||||
Objects.requireNonNull(id, "用户id不能为空");
|
||||
SysAccount account = this.sysAccountDAO.selectByPrimaryKey(id);
|
||||
updatePwdByMobileVdCode(updatePasswordVO, account);
|
||||
}
|
||||
|
||||
private void updatePwdByMobileVdCode(UpdatePasswordVO updatePasswordVO, SysAccount account) {
|
||||
if (Objects.nonNull(account)) {
|
||||
VdCode vdCode = (VdCode) this.iCacheService.get(account.getNationcode() + account.getMobile());
|
||||
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
||||
// 验证验证码
|
||||
vdCode.isValidCode(updatePasswordVO.getVfCode());
|
||||
// 验证码通过,修改密码
|
||||
account.setPassword(updatePasswordVO.getPassword());
|
||||
updatePassword4Entity(account, updatePasswordVO.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过邮箱验证码更新密码
|
||||
* @param account 要更新密码的账号
|
||||
* @param userVfCode 用户填写的验证码
|
||||
* @param newPwd 新密码
|
||||
*/
|
||||
private void updatePwdByEmailVdCode(SysAccount account, String userVfCode, String newPwd) {
|
||||
if (Objects.nonNull(account)) {
|
||||
VdCode vdCode = (VdCode) this.iCacheService.get(account.getEmail());
|
||||
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
||||
// 验证验证码
|
||||
vdCode.isValidCode(userVfCode);
|
||||
// 验证码通过,修改密码
|
||||
updatePassword4Entity(account, newPwd);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePassword4Entity(SysAccount account, String newPwd) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(newPwd, "新密码不能为空");
|
||||
account.setPassword(newPwd);
|
||||
account.setUpdateTime(LocalDateTime.now());
|
||||
this.sysAccountDAO.updateByPrimaryKey(account);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserPassword(Long id, String password) {
|
||||
@ -991,6 +1017,55 @@ public class SysUserService implements ISysUserService {
|
||||
return sysAccountDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPwd(long id) {
|
||||
String pwd = EncryptUtil.md5("123456");
|
||||
SysAccount account = getEntity(id);
|
||||
updatePassword4Entity(account, pwd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retrievePwd(RetrievePwdVO vo) {
|
||||
if (StringUtils.hasText(vo.getMobile())) {
|
||||
SysAccount account = getEntityByMobile(vo.getMobile());
|
||||
UpdatePasswordVO updatePasswordVO = new UpdatePasswordVO(vo.getVfCode(), vo.getNewPwd());
|
||||
updatePwdByMobileVdCode(updatePasswordVO, account);
|
||||
} else if (StringUtils.hasText(vo.getEmail())) {
|
||||
SysAccount account = getEntityByEmail(vo.getEmail());
|
||||
updatePwdByEmailVdCode(account, vo.getVfCode(), vo.getNewPwd());
|
||||
} else {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("手机号和邮箱不能都为空");
|
||||
}
|
||||
}
|
||||
|
||||
private SysAccount getEntityByMobile(String mobile) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(mobile);
|
||||
SysAccountExample example = new SysAccountExample();
|
||||
example.createCriteria().andMobileEqualTo(mobile);
|
||||
List<SysAccount> accounts = sysAccountDAO.selectByExample(example);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(accounts,
|
||||
String.format("[手机号:%s]的账号不存在", mobile));
|
||||
if (accounts.size() != 1) {
|
||||
log.error("[手机号:%s]的账号有多个");
|
||||
throw BusinessExceptionAssertEnum.DATA_ERROR.exception();
|
||||
}
|
||||
return accounts.get(0);
|
||||
}
|
||||
|
||||
private SysAccount getEntityByEmail(String email) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(email);
|
||||
SysAccountExample example = new SysAccountExample();
|
||||
example.createCriteria().andEmailEqualTo(email);
|
||||
List<SysAccount> accounts = sysAccountDAO.selectByExample(example);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(accounts,
|
||||
String.format("[邮箱:%s]的账号不存在", email));
|
||||
if (accounts.size() != 1) {
|
||||
log.error(String.format("[邮箱:%s]的账号有多个", email));
|
||||
throw BusinessExceptionAssertEnum.DATA_ERROR.exception();
|
||||
}
|
||||
return accounts.get(0);
|
||||
}
|
||||
|
||||
private boolean isSameEmailExist(String email) {
|
||||
SysAccountExample example = new SysAccountExample();
|
||||
example.createCriteria()
|
||||
|
@ -126,13 +126,15 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
break;
|
||||
}
|
||||
case XXYS: {
|
||||
List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false);
|
||||
czLights.forEach(light -> light.orderTo(true));
|
||||
// List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false);
|
||||
// czLights.forEach(light -> light.orderTo(true));
|
||||
ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false).orderTo(true);
|
||||
break;
|
||||
}
|
||||
case SXYS: {
|
||||
List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true);
|
||||
czLights.forEach(light -> light.orderTo(true));
|
||||
// List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true);
|
||||
// czLights.forEach(light -> light.orderTo(true));
|
||||
ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true).orderTo(true);
|
||||
break;
|
||||
}
|
||||
// case PSD_HSJC: {
|
||||
|
@ -20,4 +20,6 @@ public interface AudioResourcesService {
|
||||
PageVO<AudioResourcesVO> pagedQuery(AudioResourcesQueryVO queryVO);
|
||||
|
||||
AudioResourcesVO getById(long id);
|
||||
|
||||
void generate(AudioResourcesVO vo);
|
||||
}
|
||||
|
@ -3,12 +3,14 @@ package club.joylink.rtss.services.audio;
|
||||
import club.joylink.rtss.dao.AudioResourcesDAO;
|
||||
import club.joylink.rtss.entity.AudioResources;
|
||||
import club.joylink.rtss.entity.AudioResourcesExample;
|
||||
import club.joylink.rtss.services.voice.IVoiceService;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesQueryVO;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -21,6 +23,9 @@ import java.util.List;
|
||||
public class AudioResourcesServiceImpl implements AudioResourcesService {
|
||||
@Autowired
|
||||
private AudioResourcesDAO audioResourcesDAO;
|
||||
@Autowired
|
||||
@Qualifier("baiDuVoiceService")
|
||||
private IVoiceService iVoiceService;
|
||||
|
||||
@Override
|
||||
public void create(AudioResourcesVO vo) {
|
||||
@ -82,6 +87,13 @@ public class AudioResourcesServiceImpl implements AudioResourcesService {
|
||||
return new AudioResourcesVO(getEntity(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(AudioResourcesVO vo) {
|
||||
String filePath = iVoiceService.synthesis(vo.getDesc());
|
||||
vo.setUrl(filePath);
|
||||
create(vo);
|
||||
}
|
||||
|
||||
private AudioResources getEntity(long id) {
|
||||
return audioResourcesDAO.selectByPrimaryKey(id);
|
||||
}
|
||||
|
@ -468,6 +468,8 @@ public class AuthenticateService implements IAuthenticateService {
|
||||
case CCTV:
|
||||
case SANDBOX:
|
||||
case ILW:
|
||||
case PIS_STAND:
|
||||
case PIS_TRAIN:
|
||||
case VR_IBP: {
|
||||
RelationLoginConfigVO config = deviceVO.buildRelationLoginConfig();
|
||||
if (Objects.nonNull(config) && Objects.nonNull(config.getDeviceCode())) {
|
||||
|
@ -151,13 +151,13 @@ public class QuestionBankService implements IQuestionBankService {
|
||||
@Transactional
|
||||
public void addQuestion(QuestionVO questionVO, AccountVO accountVO) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
(Objects.equals(BusinessConsts.TheoryType.select, questionVO.getType()) ||
|
||||
Objects.equals(BusinessConsts.TheoryType.judge, questionVO.getType())) &&
|
||||
(Objects.equals(BusinessConsts.TheoryType.select.name(), questionVO.getType()) ||
|
||||
Objects.equals(BusinessConsts.TheoryType.judge.name(), questionVO.getType())) &&
|
||||
questionVO.getOptionList().stream().filter(QuestionOptionVO::getCorrect).count() == 1,
|
||||
"单选或判断题正确答案有且只有一个!");
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
(Objects.equals(BusinessConsts.TheoryType.fill, questionVO.getType()) ||
|
||||
Objects.equals(BusinessConsts.TheoryType.answer, questionVO.getType())) &&
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(
|
||||
(Objects.equals(BusinessConsts.TheoryType.fill.name(), questionVO.getType()) ||
|
||||
Objects.equals(BusinessConsts.TheoryType.answer.name(), questionVO.getType())) &&
|
||||
questionVO.getOptionList().stream().filter(op -> !op.getCorrect()).count() == 0,
|
||||
"填空或问答题不能有错误选项!");
|
||||
RaceQuestion question = questionVO.convert2DB();
|
||||
|
@ -22,4 +22,10 @@ public interface IscsSystemResourcesService {
|
||||
List<IscsSystemResourcesVO> criteriaQuery(IscsSystemResourcesQueryVO queryVO);
|
||||
|
||||
void batchCreate(List<IscsSystemResourcesVO> vos);
|
||||
|
||||
/**
|
||||
* 生成Iscs资源。
|
||||
* @param type 要生成的资源的类型,详见方法体内的注释
|
||||
*/
|
||||
void generate(long mapId, int type);
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ import club.joylink.rtss.dao.IscsSystemResourcesDAO;
|
||||
import club.joylink.rtss.entity.IscsSystemResources;
|
||||
import club.joylink.rtss.entity.IscsSystemResourcesExample;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.IMapService;
|
||||
import club.joylink.rtss.services.audio.AudioResourcesService;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesQueryVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -22,9 +25,10 @@ import java.util.List;
|
||||
public class IscsSystemResourcesServiceImpl implements IscsSystemResourcesService {
|
||||
@Autowired
|
||||
private IscsSystemResourcesDAO iscsSystemResourcesDAO;
|
||||
|
||||
@Autowired
|
||||
private AudioResourcesService audioResourcesService;
|
||||
@Autowired
|
||||
private IMapService iMapService;
|
||||
|
||||
@Override
|
||||
public void create(IscsSystemResourcesVO vo) {
|
||||
@ -106,6 +110,13 @@ public class IscsSystemResourcesServiceImpl implements IscsSystemResourcesServic
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(long mapId, int type) {
|
||||
MapVO mapDetail = iMapService.getMapDetail(mapId);
|
||||
List<MapStationNewVO> stationList = mapDetail.getGraphDataNew().getStationList();
|
||||
|
||||
}
|
||||
|
||||
private IscsSystemResources findEntityById(long id) {
|
||||
return iscsSystemResourcesDAO.selectByPrimaryKey(id);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import club.joylink.rtss.services.audio.AudioResourcesService;
|
||||
import club.joylink.rtss.services.voice.IVoiceService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityAudio;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
@ -18,6 +18,9 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ISCS交互服务
|
||||
*/
|
||||
@Component
|
||||
public class IscsInteractiveService {
|
||||
@Autowired
|
||||
@ -27,7 +30,7 @@ public class IscsInteractiveService {
|
||||
@Qualifier("baiDuVoiceService")
|
||||
private IVoiceService iVoiceService;
|
||||
|
||||
public void play(Simulation simulation, PlayParamVO param, SimulationMember member) {
|
||||
public void paPlay(Simulation simulation, PlayParamVO param, SimulationMember member) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(member != null && (member.isDispatcher() || member.isStationSupervisor()),
|
||||
"仅行调和行值可操作");
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(param.getResourceId(), "资源id不能为null");
|
||||
@ -47,6 +50,26 @@ public class IscsInteractiveService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 信号系统自动通过PA系统播放
|
||||
*/
|
||||
public void paPlayBySystem(Simulation simulation, List<String> iscsDeviceCodes,
|
||||
AudioResourcesVO audioResourcesVO, String state) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
for (String code : iscsDeviceCodes) {
|
||||
MapElement element = repository.getByCode(code);
|
||||
if (element instanceof Audio) {
|
||||
Audio audio = (Audio) element;
|
||||
audio.updateResource(audioResourcesVO);
|
||||
audio.updateState(state);
|
||||
audio.updateRemain(Audio.DEFAULT_REMAIN);
|
||||
VirtualRealityAudio vrAudio = audio.getVrAudio();
|
||||
vrAudio.updateUrl(audioResourcesVO.getUrl());
|
||||
vrAudio.control(VirtualRealityAudio.Command.PLAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void paStopPlaying(Simulation simulation, List<String> iscsDeviceCodes) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
for (String code : iscsDeviceCodes) {
|
||||
|
@ -15,6 +15,7 @@ import club.joylink.rtss.vo.client.project.*;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.hhcj.HhcjPsdConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
|
||||
@ -486,6 +487,16 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
HhcjIbpConfigVO ibpConfigVO = new HhcjIbpConfigVO();
|
||||
ibp.setConfig(ibpConfigVO.toJson());
|
||||
list.add(ibp);
|
||||
// PSD
|
||||
ProjectDevice psd = new ProjectDevice();
|
||||
psd.setProjectCode(Project.RICHOR_HHCJ.name());
|
||||
psd.setCode("hhcj-psd");
|
||||
psd.setType(ProjectDeviceType.PSD.name());
|
||||
psd.setCreator(accountVO.getId());
|
||||
psd.setCreateTime(now);
|
||||
HhcjPsdConfigVO psdConfigVO = new HhcjPsdConfigVO();
|
||||
psd.setConfig(psdConfigVO.toJson());
|
||||
list.add(psd);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
package club.joylink.rtss.services.publishData;
|
||||
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.constants.MapStatus;
|
||||
import club.joylink.rtss.dao.IscsDAO;
|
||||
import club.joylink.rtss.dao.MapDataDAO;
|
||||
import club.joylink.rtss.dao.MapInfoDAO;
|
||||
import club.joylink.rtss.entity.MapDataWithBLOBs;
|
||||
import club.joylink.rtss.entity.MapInfo;
|
||||
import club.joylink.rtss.entity.MapInfoExample;
|
||||
import club.joylink.rtss.entity.*;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.IMapService;
|
||||
import club.joylink.rtss.services.cache.ICacheService;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
@ -21,14 +23,12 @@ import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PublishMapDataHandler {
|
||||
@ -38,6 +38,10 @@ public class PublishMapDataHandler {
|
||||
private MapInfoDAO mapInfoDAO;
|
||||
@Autowired
|
||||
private MapDataDAO mapDataDAO;
|
||||
@Autowired
|
||||
private IscsDAO iscsDAO;
|
||||
@Autowired
|
||||
private ICacheService iCacheService;
|
||||
|
||||
public List<MapInfo> queryMapInfos() {
|
||||
MapInfoExample example = new MapInfoExample();
|
||||
@ -207,4 +211,54 @@ public class PublishMapDataHandler {
|
||||
mapInfoDAO.updateByPrimaryKeySelective(map);
|
||||
this.iMapService.removeCache(mapId);
|
||||
}
|
||||
|
||||
public void changeStationName(long mapId, Map<String, String> nameMap) {
|
||||
// 修改地图数据
|
||||
MapDataWithBLOBs mapData = getMapDataEntity(mapId);
|
||||
String graphData = mapData.getGraphData();
|
||||
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
|
||||
String k = entry.getKey();
|
||||
String v = entry.getValue();
|
||||
graphData = graphData.replace(k, v);
|
||||
}
|
||||
mapData.setGraphData(graphData);
|
||||
mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData);
|
||||
// 修改ISCS数据
|
||||
IscsExample iscsExample = new IscsExample();
|
||||
iscsExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
List<Iscs> iscsList = iscsDAO.selectByExampleWithBLOBs(iscsExample);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(iscsList);
|
||||
for (Iscs iscs : iscsList) {
|
||||
String iscsGraphData = iscs.getGraphData();
|
||||
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
|
||||
String k = entry.getKey();
|
||||
String v = entry.getValue();
|
||||
iscsGraphData = iscsGraphData.replace(k, v);
|
||||
}
|
||||
iscs.setGraphData(iscsGraphData);
|
||||
iscsDAO.updateByPrimaryKeyWithBLOBs(iscs);
|
||||
}
|
||||
// 刷新缓存
|
||||
iCacheService.remove(BusinessConsts.CachePrefix.Map + mapId);
|
||||
iMapService.getMapDetail(mapId);
|
||||
}
|
||||
|
||||
private MapDataWithBLOBs getMapDataEntity(long mapId) {
|
||||
MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(mapId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapInfo);
|
||||
return getMapDataEntity(mapId, mapInfo.getVersion());
|
||||
}
|
||||
|
||||
private MapDataWithBLOBs findMapDataEntity(long mapId, String version) {
|
||||
MapDataExample example = new MapDataExample();
|
||||
example.createCriteria().andMapIdEqualTo(mapId).andVersionEqualTo(version);
|
||||
List<MapDataWithBLOBs> list = mapDataDAO.selectByExampleWithBLOBs(example);
|
||||
return CollectionUtils.isEmpty(list) ? null : list.get(0);
|
||||
}
|
||||
|
||||
private MapDataWithBLOBs getMapDataEntity(long mapId, String version) {
|
||||
MapDataWithBLOBs entity = findMapDataEntity(mapId, version);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@ -26,6 +27,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThirdAccountDataSyncService {
|
||||
|
||||
@ -88,6 +90,8 @@ public class ThirdAccountDataSyncService {
|
||||
String body = JsonUtils.writeValueAsString(syncRecordData);
|
||||
HttpEntity<String> httpEntity = new HttpEntity<>(body, headers);
|
||||
ResponseEntity<String> responseEntity = this.restTemplate.postForEntity(url, httpEntity, String.class);
|
||||
log.info("向第三方发送数据:" + body);
|
||||
log.info("第三方同步数据接口Response:" + responseEntity);
|
||||
}
|
||||
|
||||
private Map<String, Object> buildSyncUserSimulationRecordData(AccountVO accountVO, UserSimulationStats record) {
|
||||
|
@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@ -190,6 +191,10 @@ public abstract class Simulation<U extends SimulationUser, M extends SimulationM
|
||||
return this.systemTime;
|
||||
}
|
||||
|
||||
public long getSystemTimeStamp() {
|
||||
return getSystemTime().toInstant(ZoneOffset.UTC).toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿真初始化
|
||||
*/
|
||||
|
@ -1,12 +1,15 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationDestroyEvent;
|
||||
import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent;
|
||||
import club.joylink.rtss.simulation.event.SimulationFaultRemoveEvent;
|
||||
import club.joylink.rtss.simulation.event.SimulationMemberPlayChangeEvent;
|
||||
import club.joylink.rtss.simulation.messaging.websocket.DefaultMessageSender;
|
||||
import club.joylink.rtss.simulation.vo.SimulationFaultVO;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -20,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@ -31,6 +35,19 @@ public class SimulationManager {
|
||||
|
||||
public static final Map<String, Simulation> simulationCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 数据过期时间
|
||||
*/
|
||||
private final static long EXPIRE_SECTION_TIME_MIN = 10;
|
||||
/**
|
||||
* 区段的缓存
|
||||
* key 对应的方向类型
|
||||
* EXPIRE_SECTION_TIME_MIN 数据过期时间
|
||||
*/
|
||||
private final static Cache<String,List<Section>> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
|
||||
// private final static Cache<String,List<Section>> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
|
||||
|
||||
|
||||
public static final int Destroy_Time = 180; // RtSimulation无用户时销毁时间,单位s
|
||||
@Scheduled(fixedRate = 5000)
|
||||
public void cleanUselessRtSimulation() {
|
||||
@ -61,6 +78,15 @@ public class SimulationManager {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void putSectionDirCache(String type,List<Section> list){
|
||||
ROAD_TYPE_CACHE.put(type,list);
|
||||
}
|
||||
|
||||
public List<Section> getSectionDir(String type){
|
||||
return ROAD_TYPE_CACHE.getIfPresent(type);
|
||||
|
||||
}
|
||||
/**
|
||||
* 保存仿真
|
||||
* @return 需要销毁的仿真
|
||||
@ -113,8 +139,11 @@ public class SimulationManager {
|
||||
}
|
||||
|
||||
public Simulation destroy(String id) {
|
||||
|
||||
Simulation simulation = simulationCache.remove(id);
|
||||
if (simulation != null) {
|
||||
ROAD_TYPE_CACHE.invalidate(simulation.getId() + "-" + Section.SectionRoadType.LEFT.name());
|
||||
ROAD_TYPE_CACHE.invalidate(simulation.getId() + "-" + Section.SectionRoadType.RIGHT.name());
|
||||
if (simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation) {
|
||||
this.applicationContext.publishEvent(new SimulationDestroyEvent(this, (club.joylink.rtss.simulation.cbtc.Simulation) simulation));
|
||||
}
|
||||
|
@ -30,7 +30,14 @@ public class ATSLogicLoop {
|
||||
this.atsStationService.updateFieldThatChangeOverTime(simulation);
|
||||
}
|
||||
|
||||
public void runForTrainPosition(Simulation simulation){
|
||||
this.atsTrainMonitorService.monitorForTrainPosition(simulation);
|
||||
}
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJob(SimulationModule.ATS.name(), () -> this.run(simulation), SimulationConstants.ATS_LOOP_RATE);
|
||||
}
|
||||
|
||||
public void addJobsForTrainPosition(Simulation simulation){
|
||||
simulation.addJob(SimulationModule.ATS.name(), () -> this.runForTrainPosition(simulation), SimulationConstants.ATS_LOOP_RATE);
|
||||
}
|
||||
}
|
||||
|
@ -281,12 +281,10 @@ public class ATSMessageCollectAndDispatcher {
|
||||
|
||||
/**
|
||||
* 同步仿真系统时间给客户端
|
||||
*
|
||||
* @param simulation
|
||||
*/
|
||||
public void syncTime(Simulation simulation) {
|
||||
Set<String> sessions = simulation.getSimulationUserIds();
|
||||
SocketMessageVO<Integer> timeSyncMessage = SocketMessageFactory.buildSimulationTimeSyncMessage(simulation);
|
||||
SocketMessageVO<Long> timeSyncMessage = SocketMessageFactory.buildSimulationTimeSyncMessage(simulation);
|
||||
stompMessageService.sendToUser(sessions, timeSyncMessage);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class IscsOperateHandler {
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.ISCS_PA_Play)
|
||||
public void paPlay(Simulation simulation, PlayParamVO playParamVO, SimulationMember member) {
|
||||
iscsInteractiveService.play(simulation, playParamVO, member);
|
||||
iscsInteractiveService.paPlay(simulation, playParamVO, member);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ public class IscsOperateHandler {
|
||||
* PIS系统停止播放
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.ISCS_PIS_Stop_Playing)
|
||||
public void pisPlay(Simulation simulation, List<String> iscsDeviceCodes) {
|
||||
public void pisStopPlaying(Simulation simulation, List<String> iscsDeviceCodes) {
|
||||
iscsInteractiveService.pisStopPlaying(simulation, iscsDeviceCodes);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,13 @@ public class AtsTrainMonitorService {
|
||||
@Autowired
|
||||
private OnBoardPisService onBoardPisService;
|
||||
|
||||
|
||||
public void monitorForTrainPosition(Simulation simulation){
|
||||
List<TrainInfo> trainList = simulation.getRepository().getSuperviseTrainList();
|
||||
for (TrainInfo trainInfo : trainList) {
|
||||
this.atsTrainTrackingService.track(simulation, trainInfo);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 列车监控逻辑
|
||||
* @param simulation
|
||||
|
@ -1,86 +1,83 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.TrainLoadParam2;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationRunAsPlanEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NewAtsTrainLoadService extends AtsTrainLoadService {
|
||||
public class NewAtsTrainLoadService {
|
||||
|
||||
@Resource
|
||||
private VRTrainRunningService vrTrainRunningService;
|
||||
private void culStation(VirtualRealityTrain train , Section section, TrainPosition tp){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
String tripNumber = tp.getTrainTripNum();
|
||||
TrainInfo trainInfo = repository.getTrainInfoMap().values().stream().filter(train -> tripNumber.equals(train.getTripNumber())).findFirst().orElse(null);
|
||||
|
||||
// List<VirtualRealityTrain> allVrTrain = repository.getAllVrTrain();
|
||||
|
||||
if(Objects.nonNull(trainInfo)){
|
||||
//存在列车需要更新位置
|
||||
Optional<VirtualRealityTrain> virtualRealityTrainOptional = repository.getAllVrTrain().stream().filter(d->Objects.equals(d.getTripNumber(),tripNumber)).findFirst();
|
||||
VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
|
||||
Station station = section.getStation();
|
||||
if(Objects.isNull(station)){
|
||||
return;
|
||||
}
|
||||
/*List<Stand> stands = station.getLdStandList();
|
||||
if(tp.isRight()){
|
||||
stands = station.getRdStandList();
|
||||
}*/
|
||||
VirtualRealityTrain.Door door = train.getDoor1();
|
||||
if(tp.isRight()){
|
||||
door = train.getDoor2();
|
||||
}
|
||||
if(tp.isStop()){
|
||||
/*for (Stand stand : stands) {
|
||||
Section ss = stand.getSection();
|
||||
System.out.println(ss.getCode());
|
||||
stand.setTrainParking(true);
|
||||
stand.getPsd().getVirtualScreenDoor().setClose(tp.isCloseDoor());
|
||||
}*/
|
||||
door.setClose(tp.isCloseDoor());
|
||||
train.setSpeed(0);
|
||||
}else{
|
||||
|
||||
Optional<VirtualRealityTrain> virtualRealityTrainOptional = repository.getAllVrTrain().stream()
|
||||
.filter(vrTrain -> !repository.isVrTrainOnline(vrTrain.getGroupNumber()))
|
||||
.findFirst();
|
||||
VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
|
||||
// 设置列车车次
|
||||
virtualRealityTrain.setTripNumber(tripNumber);
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
// SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
|
||||
// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
|
||||
/*for (Stand stand : stands) {
|
||||
stand.setTrainParking(false);
|
||||
}*/
|
||||
door.setClose(tp.isCloseDoor());
|
||||
train.setSpeed(99F);
|
||||
}
|
||||
|
||||
}
|
||||
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Map<String,VirtualRealityTrain> trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
|
||||
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
|
||||
log.error("没有找到对应车组号 param:{}",tp);
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
|
||||
if(Objects.nonNull(virtualRealityTrain)){
|
||||
//存在列车需要更新位置
|
||||
culStation(virtualRealityTrain,section,tp);
|
||||
virtualRealityTrain.setRunLevel(RunLevel.IL);
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
}else{
|
||||
virtualRealityTrain = trainMap.get(tp.getGroupNum());
|
||||
culStation(virtualRealityTrain,section,tp);
|
||||
virtualRealityTrain.setRunLevel(RunLevel.IL);
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -99,9 +96,12 @@ public class NewAtsTrainLoadService extends AtsTrainLoadService {
|
||||
//重叠检测
|
||||
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
|
||||
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
||||
boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
||||
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
||||
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
||||
// if(willOverlap){
|
||||
// return;
|
||||
// }
|
||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
||||
// 列车上线并构建ATS监控列车信息
|
||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
|
||||
}
|
||||
|
@ -6,8 +6,13 @@ import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -15,9 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -28,41 +31,47 @@ public class TrainPositionService {
|
||||
private NewAtsTrainLoadService newAtsTrainLoadService;
|
||||
@Resource
|
||||
private SimulationManager simulationManager;
|
||||
/**
|
||||
* 数据过期时间
|
||||
*/
|
||||
private final static long EXPIRE_SECTION_TIME_MIN = 10;
|
||||
/**
|
||||
* 区段的缓存
|
||||
* key 对应的方向类型
|
||||
* EXPIRE_SECTION_TIME_MIN 数据过期时间
|
||||
*/
|
||||
private final static Cache<Section.SectionRoadType,List<Section>> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
|
||||
@Resource
|
||||
StompMessageService messageService;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化或更新列车的位置
|
||||
* @param mapName
|
||||
* @param json
|
||||
*/
|
||||
|
||||
public void initTrainOrUpdate(String mapName,String json){
|
||||
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
|
||||
tp.setReceiveTime(System.currentTimeMillis());
|
||||
// log.info(tp.toString());
|
||||
List<Simulation> simulationList = this.findSimulationList(mapName);
|
||||
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
|
||||
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
|
||||
return;
|
||||
}
|
||||
// boolean d = true;
|
||||
SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
this.messageService.send(vo);
|
||||
|
||||
List<Section> sectionList = findDirectionAllSection(simulationList.get(0),tp.getRoadType());
|
||||
for (Simulation sim : simulationList) {
|
||||
List<Section> sectionList = findDirectionAllSection(sim,tp.getRoadType());
|
||||
Section section = this.findSecion(sectionList,tp);
|
||||
// if(d){
|
||||
// tp.setSectionCode(section.getCode());
|
||||
// log.info(tp.toString());
|
||||
// d = false;
|
||||
// }
|
||||
if(Objects.isNull(section)){
|
||||
log.error("未找到对应的区段 param:{}",json);
|
||||
return;
|
||||
}
|
||||
for (Simulation sim : simulationList) {
|
||||
log.info(tp.toString());
|
||||
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据传入的参数 定位对应的所在的区段
|
||||
* @param sectionList
|
||||
@ -70,7 +79,7 @@ public class TrainPositionService {
|
||||
* @return
|
||||
*/
|
||||
private Section findSecion(List<Section> sectionList,TrainPosition tp){
|
||||
int i = 0;
|
||||
// int i = 0;
|
||||
// Section findSection;
|
||||
for (Section section : sectionList) {
|
||||
if(tp.isRight()){
|
||||
@ -82,7 +91,7 @@ public class TrainPositionService {
|
||||
return section;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
// i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -94,19 +103,21 @@ public class TrainPositionService {
|
||||
* @param roadType
|
||||
* @return
|
||||
*/
|
||||
private static synchronized List<Section> findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
|
||||
List<Section> list = ROAD_TYPE_CACHE.getIfPresent(roadType);
|
||||
private synchronized List<Section> findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
|
||||
String key = sim.getId() + "-" + roadType.name();
|
||||
List<Section> list = simulationManager.getSectionDir(key);
|
||||
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
|
||||
list = sim.getRepository().getSectionList();
|
||||
list = list.stream().filter(d->d.getRoadType() == roadType)
|
||||
|
||||
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
|
||||
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
|
||||
ROAD_TYPE_CACHE.put(roadType,list);
|
||||
simulationManager.putSectionDirCache(key,list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION
|
||||
* 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.YJDDZH
|
||||
* @param mapName
|
||||
* @return
|
||||
*/
|
||||
@ -115,8 +126,7 @@ public class TrainPositionService {
|
||||
if(d instanceof Simulation){
|
||||
Simulation sim = (Simulation) d;
|
||||
SimulationBuildParams params = sim.getBuildParams();
|
||||
boolean same = Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION;
|
||||
return same;
|
||||
return Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.YJDDZH;
|
||||
}
|
||||
return false;
|
||||
}).map(d->(Simulation) d).collect(Collectors.toList());
|
||||
|
@ -36,6 +36,10 @@ public class CiLogic {
|
||||
@Autowired
|
||||
private StationDirectionService stationDirectionService;
|
||||
|
||||
public void runForTrainPosition(Simulation simulation){
|
||||
// 采集真实设备状态
|
||||
deviceStatusCollector.collect(simulation);
|
||||
}
|
||||
public void run(Simulation simulation) {
|
||||
// 采集真实设备状态
|
||||
deviceStatusCollector.collect(simulation);
|
||||
@ -282,4 +286,9 @@ public class CiLogic {
|
||||
simulation.addJob(SimulationModule.CI.name(), () -> run(simulation), SimulationConstants.CI_LOOP_RATE);
|
||||
simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
|
||||
}
|
||||
|
||||
public void addJobsForTrainPosition(Simulation simulation){
|
||||
simulation.addJob(SimulationModule.CI.name(), () -> runForTrainPosition(simulation), SimulationConstants.CI_LOOP_RATE);
|
||||
// simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
|
||||
}
|
||||
}
|
||||
|
@ -260,6 +260,11 @@ public class CiService {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
//首区段占用
|
||||
if (route.getFirstRouteSection().isOccupied()) {
|
||||
return level;
|
||||
}
|
||||
|
||||
if (signal.isCbtcMode()) {
|
||||
level = Signal.LEVEL_Atp; // ATP级
|
||||
}
|
||||
|
@ -3,13 +3,17 @@ package club.joylink.rtss.simulation.cbtc.ISCS;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class IscsLogicLoop {
|
||||
private void run(Simulation simulation) {
|
||||
public static final String JOB_NAME = "ISCS_LOGIC_LOOP";
|
||||
public static final int RATE = 1000;
|
||||
|
||||
public void run(Simulation simulation) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
// 广播播放结束逻辑
|
||||
for (Audio audio : repository.getAudioList()) {
|
||||
if (audio.isInPa() && !audio.isNotUsed()) {
|
||||
int remain = audio.getRemainDuration();
|
||||
@ -24,6 +28,6 @@ public class IscsLogicLoop {
|
||||
}
|
||||
|
||||
public void addJob(Simulation simulation) {
|
||||
simulation.addJob(Simulation.JobName.iscsLogicLoop, () -> run(simulation), SimulationConstants.ATS_LOOP_RATE);
|
||||
simulation.addJob(JOB_NAME, () -> run(simulation), RATE);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsAudioStatusVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
|
||||
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
|
||||
|
@ -15,9 +15,10 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1Ib
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceThread;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSignalConfig;
|
||||
@ -140,12 +141,14 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
||||
case PSC:
|
||||
return ((Heb1PscConfig) config).getConfig().getPsdCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XTY:{
|
||||
switch (config.getDeviceType()) {
|
||||
case PSD:
|
||||
return ((XtyPsdConfig) config).getConfig().getPsdCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RICHOR_JOINT: {
|
||||
switch (config.getDeviceType()) {
|
||||
@ -154,6 +157,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
||||
case PSL:
|
||||
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SR_SANDBOX: {
|
||||
switch (config.getDeviceType()) {
|
||||
@ -166,12 +170,16 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
||||
case TRAIN:
|
||||
return ((SrTrainConfig) config).getConfigVO().getVrCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RICHOR_HHCJ: {
|
||||
switch (config.getDeviceType()) {
|
||||
case IBP:
|
||||
return ((HhcjIbpConfig) config).getConfigVO().getIbpCode();
|
||||
case PSD:
|
||||
return ((HhcjPsdConfig) config).getConfigVO().getPsdCode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -39,6 +39,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
@ -497,6 +498,13 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
||||
return this.getSystemTime().plusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取仿真正确时间在系统默认时区的时间戳
|
||||
*/
|
||||
public long getCorrectSystemTimeStamp() {
|
||||
return getCorrectSystemTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 仿真异常信息
|
||||
// *
|
||||
|
@ -34,8 +34,10 @@ import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
|
||||
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService;
|
||||
import club.joylink.rtss.simulation.cbtc.pis.PisLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
|
||||
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
|
||||
import club.joylink.rtss.simulation.rt.pis.PisStatusPublisher;
|
||||
import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesQueryVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO;
|
||||
@ -139,6 +141,9 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
@Autowired
|
||||
private GroupSimulationService groupSimulationService;
|
||||
|
||||
@Autowired
|
||||
private PisLogicLoop pisLogicLoop;
|
||||
|
||||
@Override
|
||||
public Simulation create(SimulationBuildParams params, String group) {
|
||||
// 构建仿真
|
||||
@ -163,8 +168,6 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
}
|
||||
// 缓存
|
||||
simulationManager.save(simulation);
|
||||
// TODO: 2021/9/10 暂时放在这里
|
||||
simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
|
||||
// 初始化设备状态
|
||||
deviceStatusService.init(simulation);
|
||||
depotService.loadDepotTrain(simulation);
|
||||
@ -173,13 +176,31 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
// 初始化语音指令
|
||||
List<VoiceCommandBO> voiceCommandBOList = iVoiceCommandService.getAll();
|
||||
simulation.setVoiceCommandBOList(voiceCommandBOList);
|
||||
// 添加消息发送器
|
||||
addMessagePublisher(simulation);
|
||||
// 添加任务
|
||||
addJobs(simulation);
|
||||
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
|
||||
return simulation;
|
||||
}
|
||||
|
||||
private void addMessagePublisher(Simulation simulation) {
|
||||
simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
|
||||
simulation.addMessagePublisher(new PisStatusPublisher(simulation));
|
||||
}
|
||||
|
||||
private void addJobs(Simulation simulation) {
|
||||
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
|
||||
//非武汉大屏车辆定位
|
||||
// atsLogicLoop.addJobs(simulation);
|
||||
atsLogicLoop.addJobsForTrainPosition(simulation);
|
||||
atsMessageCollectAndDispatcher.addJobs(simulation);
|
||||
// vrDeviceLogicLoop.addJobs(simulation);
|
||||
vrDeviceLogicLoop.addJobsForTrainPosition(simulation);
|
||||
// ciLogic.addJobs(simulation);
|
||||
ciLogic.addJobsForTrainPosition(simulation);
|
||||
return;
|
||||
}
|
||||
if (simulation.getRepository().getConfig().isRailway()) {
|
||||
ctcLogicLoop.addJobs(simulation);
|
||||
} else {
|
||||
@ -190,14 +211,11 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
iVirtualRealityPslService.addJobs(simulation);
|
||||
iscsMessageCollectAndDispatcher.addJob(simulation);
|
||||
iscsLogicLoop.addJob(simulation);
|
||||
pisLogicLoop.addJobs(simulation);
|
||||
}
|
||||
atpLogicLoop.addJobs(simulation);
|
||||
|
||||
if(simulation.getBuildParams().getProdType() != MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION){
|
||||
//非武汉大屏车辆定位
|
||||
atsLogicLoop.addJobs(simulation);
|
||||
simulationRobotService.addJobs(simulation);
|
||||
}
|
||||
vrTrainRunningService.addJobs(simulation);
|
||||
ciLogic.addJobs(simulation);
|
||||
vrDeviceLogicLoop.addJobs(simulation);
|
||||
|
@ -3,11 +3,11 @@ package club.joylink.rtss.simulation.cbtc.build;
|
||||
import club.joylink.rtss.entity.Ibp;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TerminalDeparturePlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
|
@ -5,6 +5,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.communication.vo.TrainHmiDisplay;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan;
|
||||
@ -852,6 +853,7 @@ public class SimulationDataRepository {
|
||||
|
||||
/**
|
||||
* 此方法只能用于计划车次号唯一的线路(比如西门子风格的运行计划)
|
||||
*
|
||||
* @param tripNumber
|
||||
* @return
|
||||
*/
|
||||
@ -1242,6 +1244,18 @@ public class SimulationDataRepository {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Stream<Audio> getAudioStream() {
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> device instanceof Audio)
|
||||
.map(device -> (Audio) device);
|
||||
}
|
||||
|
||||
public List<Audio> getAudioList(Station station) {
|
||||
return getAudioStream()
|
||||
.filter(audio -> Objects.equals(audio.getStation(), station))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Audio> getAudioList(IscsSystem system, IscsDeviceVO.Position position) {
|
||||
Stream<Audio> stream = deviceMap.values().stream()
|
||||
.filter(device -> device instanceof Audio)
|
||||
|
@ -2,9 +2,14 @@ package club.joylink.rtss.simulation.cbtc.data;
|
||||
|
||||
import club.joylink.rtss.constants.IscsSystem;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.OnboardPis;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.StandPis;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.OnboardPisStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.StandPisStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
|
||||
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -13,12 +18,32 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class SimulationIscsDataRepository {
|
||||
private final Map<String, IscsStatusVO> statusVOMap = new HashMap<>();
|
||||
|
||||
private final List<IscsSystemResourcesVO> systemResources = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* k - name
|
||||
*/
|
||||
private final Map<String, AudioResourcesVO> audioResourcesVOMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* k - groupNumber
|
||||
*/
|
||||
private final Map<String, OnboardPis> onBoardPisMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* k - standCode
|
||||
*/
|
||||
private final Map<String, StandPis> standPisMap = new HashMap<>();
|
||||
|
||||
private final Map<String, OnboardPisStatus> onboardPisStatusMap = new HashMap<>();
|
||||
|
||||
private final Map<String, StandPisStatus> standPisStatusMap = new HashMap<>();
|
||||
|
||||
public IscsStatusVO findStatus(String iscsCode) {
|
||||
return statusVOMap.get(iscsCode);
|
||||
}
|
||||
@ -67,14 +92,27 @@ public class SimulationIscsDataRepository {
|
||||
throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception(String.format("id为[%s]的资源不存在", resourceId));
|
||||
}
|
||||
|
||||
public AudioResourcesVO findAudioResource(String name) {
|
||||
return audioResourcesVOMap.get(name);
|
||||
}
|
||||
|
||||
public void addSystemResources(List<IscsSystemResourcesVO> resourcesVOS) {
|
||||
if (!CollectionUtils.isEmpty(resourcesVOS)) {
|
||||
systemResources.addAll(resourcesVOS);
|
||||
resourcesVOS.stream()
|
||||
.filter(iscsSystemResourcesVO -> !IscsSystemResourcesVO.Type.REAL_TIME.equals(iscsSystemResourcesVO.getType()))
|
||||
.flatMap(iscsSystemResourcesVO -> iscsSystemResourcesVO.getResources().stream())
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(audioResourcesVO -> audioResourcesVOMap.put(audioResourcesVO.getName(), audioResourcesVO));
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.statusVOMap.clear();
|
||||
this.systemResources.removeIf(vo -> IscsSystemResourcesVO.Type.REAL_TIME.equals(vo.getType()));
|
||||
this.onBoardPisMap.clear();
|
||||
this.onboardPisStatusMap.clear();
|
||||
this.standPisMap.clear();
|
||||
this.standPisStatusMap.clear();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.info;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 车载Pis
|
||||
*/
|
||||
@Getter
|
||||
public class OnboardPis {
|
||||
private String groupNumber;
|
||||
|
||||
/**
|
||||
* 下一抵达车站
|
||||
*/
|
||||
private Station nextStation;
|
||||
|
||||
/**
|
||||
* 终点站
|
||||
*/
|
||||
private Station endStation;
|
||||
|
||||
public OnboardPis(String groupNumber, Station nextStation, Station endStation) {
|
||||
this.groupNumber = groupNumber;
|
||||
this.nextStation = nextStation;
|
||||
this.endStation = endStation;
|
||||
}
|
||||
|
||||
public String getNextStationName() {
|
||||
return nextStation == null ? "" : nextStation.getName();
|
||||
}
|
||||
|
||||
public String getEndStationName() {
|
||||
return endStation == null ? "" : endStation.getName();
|
||||
}
|
||||
|
||||
public void update(Station nextStation, Station endStation) {
|
||||
this.nextStation = nextStation;
|
||||
this.endStation = endStation;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
nextStation = null;
|
||||
endStation = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.info;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 站台Pis
|
||||
*/
|
||||
@Getter
|
||||
public class StandPis {
|
||||
private Stand stand;
|
||||
/**
|
||||
* 本站
|
||||
*/
|
||||
private Station station;
|
||||
|
||||
private TrainInfo firstTrain;
|
||||
|
||||
/**
|
||||
* 第一辆车预计进站时间/m
|
||||
* 剩余时间为1时表示 即将进站
|
||||
* 剩余时间为0时表示 列车进站
|
||||
*/
|
||||
private Integer firstTrainRemain;
|
||||
|
||||
/**
|
||||
* 第一辆车的终点站
|
||||
*/
|
||||
private Station firstEndStation;
|
||||
|
||||
private TrainInfo secondTrain;
|
||||
|
||||
/**
|
||||
* 第二辆车预计进站时间/m
|
||||
*/
|
||||
private Integer secondTrainRemain;
|
||||
|
||||
/**
|
||||
* 第二辆车的终点站
|
||||
*/
|
||||
private Station secondEndStation;
|
||||
|
||||
/**
|
||||
* 最后一个即将进站的列车(播报了即将进站语音的列车)
|
||||
*/
|
||||
@Setter
|
||||
private TrainInfo lastComingTrain;
|
||||
|
||||
public StandPis(Stand stand, Station station) {
|
||||
this.stand = stand;
|
||||
this.station = station;
|
||||
}
|
||||
|
||||
public String getFirstEndStationName() {
|
||||
return firstEndStation == null ? "" : firstEndStation.getName();
|
||||
}
|
||||
|
||||
public String getSecondEndStationName() {
|
||||
return secondEndStation == null ? "" : secondEndStation.getName();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
firstTrainRemain = null;
|
||||
firstEndStation = null;
|
||||
secondTrainRemain = null;
|
||||
secondEndStation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换。将参数中的剩余时间与当前记录的两辆列车的信息做比较,留下时间更短的两个
|
||||
*/
|
||||
public void replace(TrainInfo train, Integer remain, Station endStation) {
|
||||
if (firstTrainRemain == null) {
|
||||
firstTrain = train;
|
||||
firstTrainRemain = remain;
|
||||
firstEndStation = endStation;
|
||||
} else if (secondTrainRemain == null) {
|
||||
secondTrain = train;
|
||||
secondTrainRemain = remain;
|
||||
secondEndStation = endStation;
|
||||
} else {
|
||||
if (remain < firstTrainRemain) {
|
||||
secondTrain = firstTrain;
|
||||
secondTrainRemain = firstTrainRemain;
|
||||
secondEndStation = firstEndStation;
|
||||
firstTrain = train;
|
||||
firstTrainRemain = remain;
|
||||
firstEndStation = endStation;
|
||||
} else if (remain < secondTrainRemain) {
|
||||
secondTrain = train;
|
||||
secondTrainRemain = remain;
|
||||
secondEndStation = endStation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一趟列车即将进站?
|
||||
*/
|
||||
public boolean firstTrainIsComing() {
|
||||
return firstTrainRemain == 1;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.map;
|
||||
package club.joylink.rtss.simulation.cbtc.data.iscs;
|
||||
|
||||
import club.joylink.rtss.constants.IscsSystem;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityAudio;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
|
||||
import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO;
|
||||
@ -13,7 +15,7 @@ import java.util.Objects;
|
||||
* 广播
|
||||
*/
|
||||
@Getter
|
||||
public class Audio extends MapElement{
|
||||
public class Audio extends MapElement {
|
||||
private IscsSystem system;
|
||||
|
||||
private Station station;
|
||||
@ -50,6 +52,10 @@ public class Audio extends MapElement{
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return vrAudio.getUrl();
|
||||
}
|
||||
|
||||
public void updateResource(AudioResourcesVO resource) {
|
||||
this.resource = resource;
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.plan;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalTime;
|
||||
@ -494,4 +496,10 @@ public class TripPlan {
|
||||
}
|
||||
return plan1.getStartTime().compareTo(plan2.getStartTime());
|
||||
}
|
||||
|
||||
public List<StationPlan> getSubList(@NonNull StationPlan stationPlan) {
|
||||
int startIndex = planList.indexOf(stationPlan);
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(startIndex != -1);
|
||||
return planList.subList(startIndex, planList.size());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.status;
|
||||
|
||||
import club.joylink.rtss.simulation.Watchable;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.OnboardPis;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 车载pis状态
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class OnboardPisStatus extends Watchable {
|
||||
/**
|
||||
* 列车编号
|
||||
*/
|
||||
private String groupNumber;
|
||||
|
||||
/**
|
||||
* 下一站的站名
|
||||
*/
|
||||
private String nextStationName;
|
||||
|
||||
/**
|
||||
* 终点站的站名
|
||||
*/
|
||||
private String endStationName;
|
||||
|
||||
public OnboardPisStatus(OnboardPis pis) {
|
||||
this.groupNumber = pis.getGroupNumber();
|
||||
this.nextStationName = pis.getNextStationName();
|
||||
this.endStationName = pis.getNextStationName();
|
||||
}
|
||||
|
||||
public OnboardPisStatus compareAndChange(OnboardPis pis) {
|
||||
boolean change = false;
|
||||
OnboardPisStatus changeStatus = new OnboardPisStatus();
|
||||
changeStatus.setGroupNumber(groupNumber);
|
||||
|
||||
if (!Objects.equals(nextStationName, pis.getNextStationName())) {
|
||||
nextStationName = pis.getNextStationName();
|
||||
change = true;
|
||||
changeStatus.setNextStationName(nextStationName);
|
||||
}
|
||||
if (!Objects.equals(endStationName, pis.getEndStationName())) {
|
||||
endStationName = pis.getEndStationName();
|
||||
change = true;
|
||||
changeStatus.setEndStationName(endStationName);
|
||||
}
|
||||
|
||||
return change ? changeStatus : null;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.status;
|
||||
|
||||
import club.joylink.rtss.simulation.Watchable;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.StandPis;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 站台pis状态
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StandPisStatus extends Watchable {
|
||||
/**
|
||||
* 该Pis信息所属的站台的code
|
||||
*/
|
||||
private String standCode;
|
||||
|
||||
/**
|
||||
* 当前车站的名称
|
||||
*/
|
||||
@JsonInclude
|
||||
private String stationName;
|
||||
|
||||
/**
|
||||
* 第一辆车预计进站时间/m
|
||||
*/
|
||||
@JsonInclude
|
||||
private Integer firstTrainRemain;
|
||||
|
||||
/**
|
||||
* 第一辆车的终点站的名称
|
||||
*/
|
||||
private String firstEndStationName;
|
||||
|
||||
/**
|
||||
* 第二辆车预计进站时间/m
|
||||
*/
|
||||
@JsonInclude
|
||||
private Integer secondTrainRemain;
|
||||
|
||||
/**
|
||||
* 第二辆车的终点站的名称
|
||||
*/
|
||||
private String secondEndStationName;
|
||||
|
||||
public StandPisStatus(StandPis pis) {
|
||||
this.standCode = pis.getStand().getCode();
|
||||
this.stationName = pis.getStation().getName();
|
||||
this.firstTrainRemain = pis.getFirstTrainRemain();
|
||||
this.firstEndStationName = pis.getFirstEndStationName();
|
||||
this.secondTrainRemain = pis.getSecondTrainRemain();
|
||||
this.secondEndStationName = pis.getSecondEndStationName();
|
||||
}
|
||||
|
||||
public StandPisStatus compareAndChange(StandPis pis) {
|
||||
boolean change = false;
|
||||
StandPisStatus changeStatus = new StandPisStatus();
|
||||
changeStatus.setStandCode(standCode);
|
||||
|
||||
if (!Objects.equals(stationName, pis.getStation().getName())) {
|
||||
stationName = pis.getStation().getName();
|
||||
change = true;
|
||||
changeStatus.setStationName(stationName);
|
||||
}
|
||||
if (!Objects.equals(firstTrainRemain, pis.getFirstTrainRemain())) {
|
||||
firstTrainRemain = pis.getFirstTrainRemain();
|
||||
change = true;
|
||||
changeStatus.setFirstTrainRemain(firstTrainRemain);
|
||||
}
|
||||
if (!Objects.equals(firstEndStationName, pis.getFirstEndStationName())) {
|
||||
firstEndStationName = pis.getFirstEndStationName();
|
||||
change = true;
|
||||
changeStatus.setFirstEndStationName(firstEndStationName);
|
||||
}
|
||||
if (!Objects.equals(secondTrainRemain, pis.getSecondTrainRemain())) {
|
||||
secondTrainRemain = pis.getSecondTrainRemain();
|
||||
change = true;
|
||||
changeStatus.setSecondTrainRemain(secondTrainRemain);
|
||||
}
|
||||
if (!Objects.equals(secondEndStationName, pis.getSecondEndStationName())) {
|
||||
secondEndStationName = pis.getSecondEndStationName();
|
||||
change = true;
|
||||
changeStatus.setSecondEndStationName(secondEndStationName);
|
||||
}
|
||||
|
||||
if (change) {
|
||||
changeStatus.setFirstTrainRemain(firstTrainRemain);
|
||||
changeStatus.setSecondTrainRemain(secondTrainRemain);
|
||||
return changeStatus;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class SimulationVO {
|
||||
|
||||
private Simulation.FunctionalType type;
|
||||
|
||||
private int systemTime;
|
||||
private long systemTime;
|
||||
|
||||
/** 数据是否存在错误 */
|
||||
private boolean dataError;
|
||||
@ -71,7 +71,6 @@ public class SimulationVO {
|
||||
creator.setId(user.getId());
|
||||
creator.setName(user.getName());
|
||||
creator.setNickname(user.getNickname());
|
||||
int systemTime = simulation.getCorrectSystemTime().toLocalTime().toSecondOfDay();
|
||||
return SimulationVO.builder()
|
||||
.group(simulation.getId())
|
||||
.map(mapVO)
|
||||
@ -81,7 +80,7 @@ public class SimulationVO {
|
||||
.prodType(Objects.nonNull(simulation.getBuildParams().getProdType()) ? simulation.getBuildParams().getProdType().getCode() : null)
|
||||
.dataError(simulation.isMapDataError() || simulation.isPlanDataError())
|
||||
.errorMsgList(simulation.getDataErrMsgList())
|
||||
.systemTime(systemTime)
|
||||
.systemTime(simulation.getCorrectSystemTimeStamp())
|
||||
.planRunning(simulation.isPlanRunning())
|
||||
.scriptId(Objects.isNull(simulation.getScript()) ? null : simulation.getScript().getId())
|
||||
.pause(simulation.isPause())
|
||||
|
@ -1,7 +1,7 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
|
||||
|
||||
import club.joylink.rtss.constants.IscsSystem;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -14,6 +14,8 @@ public class IscsAudioStatusVO extends IscsStatusVO{
|
||||
|
||||
private String state;
|
||||
|
||||
private String url;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isPaSystem() {
|
||||
return IscsSystem.PA.equals(system);
|
||||
@ -28,6 +30,7 @@ public class IscsAudioStatusVO extends IscsStatusVO{
|
||||
super(audio.getCode(), DeviceType.AUDIO, audio.getStation().getCode());
|
||||
this.system = audio.getSystem();
|
||||
this.state = audio.getState();
|
||||
this.url = audio.getUrl();
|
||||
}
|
||||
|
||||
public boolean compareAndChange(Audio audio) {
|
||||
@ -36,6 +39,10 @@ public class IscsAudioStatusVO extends IscsStatusVO{
|
||||
this.state = audio.getState();
|
||||
change = true;
|
||||
}
|
||||
if (!Objects.equals(this.url, audio.getUrl())) {
|
||||
this.url = audio.getUrl();
|
||||
change = true;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
}
|
||||
|
@ -91,4 +91,8 @@ public abstract class ControllableVrDevice<C> extends VirtualRealityDevice {
|
||||
* @param command
|
||||
*/
|
||||
protected abstract void doFinish(C command);
|
||||
|
||||
void setRemain(int remain) {
|
||||
this.remain = remain;
|
||||
}
|
||||
}
|
||||
|
@ -69,28 +69,44 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
|
||||
this.fault = null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected boolean checkConditionBeforeControl(Operation command) {
|
||||
// //已是关门到位状态,发送关门指令依然会进入转换中状态,导致门又开启,遂加此限制
|
||||
// switch (command) {
|
||||
// case K:{
|
||||
// if (this.isOpen2End())
|
||||
// return false;
|
||||
// break;
|
||||
// }
|
||||
// case G: {
|
||||
// if (this.isLockAndClose())
|
||||
// return false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected boolean checkConditionBeforeControl(Operation command) {
|
||||
//已是关门到位状态,发送关门指令依然会进入转换中状态,导致门又开启,遂加此限制
|
||||
switch (command) {
|
||||
protected void doTurn() {
|
||||
switch (getCommand()) {
|
||||
case K:{
|
||||
if (this.isOpen2End())
|
||||
return false;
|
||||
setRemain(0);
|
||||
else
|
||||
setClose(false);
|
||||
break;
|
||||
}
|
||||
case G: {
|
||||
if (this.isLockAndClose())
|
||||
return false;
|
||||
setRemain(0);
|
||||
else
|
||||
setOpen2End(false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + getCommand());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTurn() {
|
||||
this.setClose(false);
|
||||
this.open2End = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,6 +92,9 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
|
||||
boolean w_psd_sx_sdcz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psd_sx_sdcz());
|
||||
boolean w_psd_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psd_sx_hsjc());
|
||||
|
||||
boolean w_psd_real_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psd_real_km());
|
||||
boolean w_psd_real_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psd_real_gm());
|
||||
|
||||
iVirtualRealityIbpService.updateOnOrOff(simulation, vrIbp, VirtualRealityIbp.Mean.kcLight, false, w_xh_xx_kc_light);
|
||||
iVirtualRealityIbpService.updateOnOrOff(simulation, vrIbp, VirtualRealityIbp.Mean.jjtcLight, false, w_xh_xx_jjtc_light);
|
||||
iVirtualRealityIbpService.updateOnOrOff(simulation, vrIbp, VirtualRealityIbp.Mean.SIGNAL_ALARM, null, w_xh_fmq);
|
||||
@ -151,6 +154,8 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
|
||||
on = true;
|
||||
} else if (element.isTurnOff()) {
|
||||
on = false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
boolean currentIsOn = false;
|
||||
Integer addr = null;
|
||||
@ -276,7 +281,7 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
|
||||
case PRERESET_Z:
|
||||
break;
|
||||
}
|
||||
if (addr != null && on != null) {
|
||||
if (addr != null) {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, addr, currentIsOn, on, channel);
|
||||
}
|
||||
}
|
||||
@ -535,6 +540,7 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
|
||||
boolean w_xfsb_gzwyb2 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xfsb_gzwyb2());
|
||||
boolean w_xfsb_gsw = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xfsb_gsw());
|
||||
boolean w_xfsb_dsw = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xfsb_dsw());
|
||||
boolean w_zj_real = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zj_real());
|
||||
// 按钮灯
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_qjsb_qd1A(), w_qjsb_qd1A, r_qjsb_qd1A, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_qjsb_qd1B(), w_qjsb_qd1B, r_qjsb_qd1B, channel);
|
||||
@ -580,5 +586,7 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xfsb_gzwyb2(), w_xfsb_gzwyb2, r_xfsb_sd, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xfsb_gsw(), w_xfsb_gsw, r_xfsb_sd, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xfsb_dsw(), w_xfsb_dsw, r_xfsb_sd, channel);
|
||||
// 闸机控制
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zj_real(), w_zj_real, r_zj_jjsf, channel);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||
import club.joylink.rtss.vo.client.project.hhcj.HhcjPsdConfigVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class HhcjPsdConfig extends RealDeviceConfig {
|
||||
private HhcjPsdConfigVO configVO;
|
||||
|
||||
public HhcjPsdConfig(ProjectDeviceVO projectDevice) {
|
||||
super(projectDevice);
|
||||
if (projectDevice != null) {
|
||||
this.configVO = JsonUtils.read(projectDevice.getConfig(), HhcjPsdConfigVO.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.vo.client.project.hhcj.HhcjPsdConfigVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class HhcjPsdServiceImpl implements RealDeviceService {
|
||||
@Autowired
|
||||
private PlcGatewayService plcGatewayService;
|
||||
|
||||
@Override
|
||||
public boolean canHandle(RealDeviceConfig deviceConfig) {
|
||||
return deviceConfig instanceof HhcjPsdConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
|
||||
//不需要初始化逻辑,因为所有的状态都来源于IBP盘上按钮的状态
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||
if (plcGateway == null)
|
||||
return;
|
||||
HhcjPsdConfig config = (HhcjPsdConfig) deviceConfig;
|
||||
VirtualRealityScreenDoor vrPsd = (VirtualRealityScreenDoor) config.getMapElement();
|
||||
if (vrPsd == null)
|
||||
return;
|
||||
HhcjPsdConfigVO configVO = config.getConfigVO();
|
||||
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
|
||||
|
||||
boolean w_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km());
|
||||
boolean w_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm());
|
||||
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
|
||||
boolean newKm;
|
||||
boolean newGm;
|
||||
if (vrPsd.isSettingOpen()) {
|
||||
newKm = true;
|
||||
newGm = false;
|
||||
} else if (vrPsd.isSettingClose()) {
|
||||
newKm = false;
|
||||
newGm = true;
|
||||
} else {
|
||||
newKm = false;
|
||||
newGm = false;
|
||||
}
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km(), w_km, newKm, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm(), w_gm, newGm, channel);
|
||||
|
||||
if (vrPsd.getRemain() > 0) {
|
||||
vrPsd.turning(SimulationModule.VRD.getRateMs());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.services.IVirtualRealityIbpService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
|
||||
|
||||
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
|
@ -26,6 +26,10 @@ public class VRDeviceLogicLoop {
|
||||
@Autowired
|
||||
private VirtualRealityDeviceService virtualRealityDeviceService;
|
||||
|
||||
public void runForTrainPosition(Simulation simulation){
|
||||
// 列车占压计轴区段检查
|
||||
this.updateTrainOccupySection(simulation);
|
||||
}
|
||||
public void run(Simulation simulation) {
|
||||
// long start = System.currentTimeMillis();
|
||||
// 虚拟真实道岔转动过程
|
||||
@ -85,4 +89,7 @@ public class VRDeviceLogicLoop {
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJob(SimulationModule.VRD.name(), () -> this.run(simulation), SimulationConstants.VRD_LOOP_RATE);
|
||||
}
|
||||
public void addJobsForTrainPosition(Simulation simulation) {
|
||||
simulation.addJob(SimulationModule.VRD.name(), () -> this.runForTrainPosition(simulation), SimulationConstants.VRD_LOOP_RATE);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ public enum SimulationSubscribeTopic {
|
||||
PassengerFlow("/queue/simulation/passenger/{id}"),
|
||||
WeChatMini("/topic/simulation/assistant/{id}"),
|
||||
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
|
||||
Room("/queue/room/{id}"),
|
||||
Wgu3d("/topic/simulation/wgu3d/{id}"),
|
||||
YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition")
|
||||
;
|
||||
|
||||
private String destPattern;
|
||||
|
@ -117,7 +117,7 @@ public class UserSimulationStatsManager {
|
||||
Set<SimulationUseInfo> infos = userAndUseInfosMap.get(info.getUserId());
|
||||
infos.removeIf(i -> group.equals(i.getGroup()));
|
||||
});
|
||||
useInfos.forEach(info -> {
|
||||
useInfos.stream().filter(d->Objects.nonNull(d.prdType)).forEach(info -> {
|
||||
iUserSimulationStatService.addUserSimulationStats(info);
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,205 @@
|
||||
package club.joylink.rtss.simulation.cbtc.pis;
|
||||
|
||||
import club.joylink.rtss.services.iscs.interactive.IscsInteractiveService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.OnboardPis;
|
||||
import club.joylink.rtss.simulation.cbtc.data.info.StandPis;
|
||||
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.OnboardPisStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.StandPisStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.rt.pis.PisStatusPublisher;
|
||||
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
|
||||
import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Pis系统逻辑循环。
|
||||
*/
|
||||
@Component
|
||||
public class PisLogicLoop {
|
||||
public static final String LOGIC_JOB_NAME = "PIS_LOGIC";
|
||||
public static final int RATE = 1000;
|
||||
public static final String MESSAGE_JOB_NAME = "PIS_MESSAGE";
|
||||
|
||||
@Autowired
|
||||
private IscsInteractiveService iscsInteractiveService;
|
||||
|
||||
public void run(Simulation simulation) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
|
||||
Map<String, OnboardPis> onBoardPisMap = iscsRepository.getOnBoardPisMap();
|
||||
onBoardPisMap.values().forEach(OnboardPis::clear); //清除过期数据
|
||||
Map<String, StandPis> standPisMap = iscsRepository.getStandPisMap();
|
||||
standPisMap.values().forEach(StandPis::clear); //清除过期数据
|
||||
List<TrainInfo> superviseTrainList = repository.getSuperviseTrainList();
|
||||
for (TrainInfo trainInfo : superviseTrainList) {
|
||||
// 车载PIS信息更新逻辑
|
||||
//下一站
|
||||
Station nextStation = null;
|
||||
String nextStandTrackCode = trainInfo.getEstimatedArriveStandTrack();
|
||||
if (StringUtils.hasText(nextStandTrackCode)) {
|
||||
Section standTrack = repository.getByCode(nextStandTrackCode, Section.class);
|
||||
List<Stand> standList = standTrack.getStandList();
|
||||
if (!CollectionUtils.isEmpty(standList) && !standList.get(0).isSmall()) {
|
||||
nextStation = standList.get(0).getStation();
|
||||
}
|
||||
}
|
||||
//终点站
|
||||
Station endStation = null;
|
||||
if (StringUtils.hasText(trainInfo.getEndStation())) {
|
||||
endStation = repository.getByCode(trainInfo.getEndStation(), Station.class);
|
||||
}
|
||||
|
||||
OnboardPis onboardPis = onBoardPisMap.get(trainInfo.getGroupNumber());
|
||||
if (onboardPis != null) {
|
||||
onboardPis.update(nextStation, endStation);
|
||||
} else {
|
||||
onboardPis = new OnboardPis(trainInfo.getGroupNumber(), nextStation, endStation);
|
||||
onBoardPisMap.put(onboardPis.getGroupNumber(), onboardPis);
|
||||
}
|
||||
|
||||
//站台PIS信息更新
|
||||
TripPlan tripPlan = repository.queryTripPlan(trainInfo.getTripNumber());
|
||||
if (tripPlan == null)
|
||||
continue;
|
||||
List<StationPlan> planList = tripPlan.getPlanList();
|
||||
int index;
|
||||
StandPis standPis = null;
|
||||
if (trainInfo.isParking()) { //当列车停站时,剩余时间计算方式与通常不同,必须为0,所以独立出来
|
||||
StationPlan stationPlan = tripPlan.queryStationPlan(trainInfo.getActualArriveStandTrack());
|
||||
if (stationPlan != null) {
|
||||
List<Stand> standList = stationPlan.getSection().getStandList();
|
||||
if (!CollectionUtils.isEmpty(standList)) {
|
||||
Stand stand = standList.get(0);
|
||||
if (!stand.isSmall()) {
|
||||
standPis = standPisMap.computeIfAbsent(stand.getCode(), k -> new StandPis(stand, stationPlan.getStation()));
|
||||
standPis.replace(trainInfo, 0, endStation);
|
||||
}
|
||||
index = planList.indexOf(stationPlan) + 1;
|
||||
} else {
|
||||
index = tripPlan.getPlanIndex(trainInfo.getEstimatedArriveStandTrack());
|
||||
}
|
||||
} else {
|
||||
index = tripPlan.getPlanIndex(trainInfo.getEstimatedArriveStandTrack());
|
||||
}
|
||||
} else {
|
||||
index = tripPlan.getPlanIndex(trainInfo.getEstimatedArriveStandTrack());
|
||||
if (index != -1) {
|
||||
StationPlan stationPlan = tripPlan.getPlanList().get(index);
|
||||
if (stationPlan.getSection().getCode().equals(trainInfo.getPhysicalSection())) {
|
||||
List<Stand> standList = stationPlan.getSection().getStandList();
|
||||
if (!CollectionUtils.isEmpty(standList)) {
|
||||
Stand stand = standList.get(0);
|
||||
if (!stand.isSmall()) {
|
||||
standPis = standPisMap.computeIfAbsent(stand.getCode(), k -> new StandPis(stand, stationPlan.getStation()));
|
||||
standPis.replace(trainInfo, 1, endStation);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index != -1) {
|
||||
for (StationPlan plan : planList.subList(index, planList.size())) { //遍历未完成的计划
|
||||
long seconds = Duration.between(simulation.getSystemTime().toLocalTime(), plan.getArriveTime()).toSeconds();
|
||||
int remain = (int) (Math.ceil(seconds / 60f)); //剩余秒数转分钟后向上取整
|
||||
remain = Math.max(2, remain); //因为remain==0表示列车已经进站,所以列车没停站时remain不可以==0
|
||||
List<Stand> standList = plan.getSection().getStandList();
|
||||
if (!CollectionUtils.isEmpty(standList)) {
|
||||
Stand stand = standList.get(0);
|
||||
if (!stand.isSmall()) {
|
||||
StandPis sp = standPisMap.computeIfAbsent(stand.getCode(), k -> new StandPis(stand, plan.getStation()));
|
||||
sp.replace(trainInfo, remain, endStation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 即将到站语音播报
|
||||
if (standPis != null) {
|
||||
if (standPis.firstTrainIsComing()
|
||||
&& !Objects.equals(trainInfo, standPis.getLastComingTrain())
|
||||
&& Objects.equals(trainInfo, standPis.getFirstTrain())) { //列车即将进站且没有播报过
|
||||
String resourceName = String.format("开往%s方向的列车即将进站", standPis.getFirstEndStationName());
|
||||
AudioResourcesVO audioResource = iscsRepository.findAudioResource(resourceName);
|
||||
|
||||
if (audioResource != null) {
|
||||
boolean up = repository.getConfig().isUp(standPis.getStand().isRight()); //判断站台上下行
|
||||
IscsDeviceVO.Position audioPosition = up ? IscsDeviceVO.Position.UP_STAND : IscsDeviceVO.Position.DOWN_STAND;
|
||||
List<String> audioCodes = repository.getAudioList(standPis.getStation()).stream()
|
||||
.filter(audio -> Objects.equals(audio.getPosition(), audioPosition))
|
||||
.map(MapElement::getCode)
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(audioCodes)) {
|
||||
iscsInteractiveService.paPlayBySystem(simulation, audioCodes, audioResource, Audio.State.STATION_NORMAL);
|
||||
standPis.setLastComingTrain(trainInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatusAndSend(Simulation simulation) {
|
||||
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
|
||||
Map<String, OnboardPis> onBoardPisMap = iscsRepository.getOnBoardPisMap();
|
||||
Map<String, OnboardPisStatus> onboardPisStatusMap = iscsRepository.getOnboardPisStatusMap();
|
||||
for (OnboardPis value : onBoardPisMap.values()) {
|
||||
OnboardPisStatus status = onboardPisStatusMap.get(value.getGroupNumber());
|
||||
OnboardPisStatus changed;
|
||||
if (status == null) {
|
||||
status = new OnboardPisStatus(value);
|
||||
PisStatusPublisher watcher = simulation.getMessagePublisher(PisStatusPublisher.NAME, PisStatusPublisher.class);
|
||||
simulation.watch(status, watcher);
|
||||
onboardPisStatusMap.put(status.getGroupNumber(), status);
|
||||
changed = status;
|
||||
} else {
|
||||
changed = status.compareAndChange(value);
|
||||
}
|
||||
if (changed != null) {
|
||||
status.fireWatcher(null, null);
|
||||
}
|
||||
}
|
||||
Map<String, StandPis> standPisMap = iscsRepository.getStandPisMap();
|
||||
Map<String, StandPisStatus> standPisStatusMap = iscsRepository.getStandPisStatusMap();
|
||||
for (StandPis value : standPisMap.values()) {
|
||||
StandPisStatus status = standPisStatusMap.get(value.getStand().getCode());
|
||||
StandPisStatus changed;
|
||||
if (status == null) {
|
||||
status = new StandPisStatus(value);
|
||||
PisStatusPublisher watcher = simulation.getMessagePublisher(PisStatusPublisher.NAME, PisStatusPublisher.class);
|
||||
simulation.watch(status, watcher);
|
||||
standPisStatusMap.put(status.getStandCode(), status);
|
||||
changed = status;
|
||||
} else {
|
||||
changed = status.compareAndChange(value);
|
||||
}
|
||||
if (changed != null) {
|
||||
status.fireWatcher(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJobIfAbsent(LOGIC_JOB_NAME, () -> run(simulation), RATE);
|
||||
simulation.addFixedRateJob(MESSAGE_JOB_NAME, () -> updateStatusAndSend(simulation), RATE);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package club.joylink.rtss.simulation.rt.pis;
|
||||
|
||||
import club.joylink.rtss.simulation.Simulation;
|
||||
import club.joylink.rtss.simulation.SimulationTriggerMessagePublisher;
|
||||
import club.joylink.rtss.simulation.Watchable;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.OnboardPisStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.StandPisStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pis状态发布
|
||||
*/
|
||||
public class PisStatusPublisher extends SimulationTriggerMessagePublisher {
|
||||
public static final String NAME = "PisMP";
|
||||
public static final String STAND_PIS_PATH = "standPis";
|
||||
public static final String STAND_PIS_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, STAND_PIS_PATH, "{standCode}");
|
||||
public static final String ONBOARD_PIS_PATH = "onboardPis";
|
||||
public static final String ONBOARD_PIS_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, ONBOARD_PIS_PATH, "{groupNumber}");
|
||||
|
||||
private club.joylink.rtss.simulation.cbtc.Simulation simulation;
|
||||
public PisStatusPublisher(club.joylink.rtss.simulation.cbtc.Simulation simulation) {
|
||||
super(NAME, List.of(STAND_PIS_PATTERN, ONBOARD_PIS_PATTERN));
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object buildMessageOfSubscribe(String destination) {
|
||||
List<String> list = this.getDestinationParamsMap().get(destination);
|
||||
Object result = null;
|
||||
if (destination.contains(STAND_PIS_PATH)) {
|
||||
String standCode = list.get(1);
|
||||
result = simulation.getIscsRepository().getStandPisStatusMap().get(standCode);
|
||||
} else if (destination.contains(ONBOARD_PIS_PATH)) {
|
||||
String groupNumber = list.get(1);
|
||||
result = simulation.getIscsRepository().getOnboardPisStatusMap().get(groupNumber);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNeedBuildDestination(Watchable watchable) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Map.Entry<String, List<String>> entry : this.getDestinationParamsMap().entrySet()) {
|
||||
String destination = entry.getKey();
|
||||
List<String> param = entry.getValue();
|
||||
if (watchable instanceof OnboardPisStatus) {
|
||||
if (param.get(1).equals(((OnboardPisStatus) watchable).getGroupNumber())) {
|
||||
list.add(destination);
|
||||
}
|
||||
} else if (watchable instanceof StandPisStatus) {
|
||||
if (param.get(1).equals(((StandPisStatus) watchable).getStandCode())) {
|
||||
list.add(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object buildMessage(Watchable watchable) {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// if (watchable instanceof OnboardPisStatus) {
|
||||
// map.put("onboardPis", Collections.singletonList(watchable));
|
||||
// } else if (watchable instanceof StandPisStatus) {
|
||||
// map.put("standPis", Collections.singletonList(watchable));
|
||||
// }
|
||||
// return map;
|
||||
return watchable;
|
||||
}
|
||||
}
|
115
src/main/java/club/joylink/rtss/util/test/LogTest.java
Normal file
115
src/main/java/club/joylink/rtss/util/test/LogTest.java
Normal file
@ -0,0 +1,115 @@
|
||||
package club.joylink.rtss.util.test;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LogTest {
|
||||
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
LogTest lt = new LogTest();
|
||||
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
||||
// lt.query(list,"024");
|
||||
list = lt.query(list,"015",Section.SectionRoadType.RIGHT);
|
||||
for (TrainPosition tp : list) {
|
||||
System.out.println(tp.dateFormat() + " --->" + tp.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void queryAll(List<TrainPosition> list){
|
||||
Map<String,List<TrainPosition>> mapList = list.stream()
|
||||
.sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.groupingBy(d->d.getGroupNum() + "-" + d.getRoadType().name()));
|
||||
mapList.forEach((k,v)->{
|
||||
|
||||
try(BufferedWriter writer = new BufferedWriter(new FileWriter("d:\\usr\\" + k))){
|
||||
for (TrainPosition tp : v) {
|
||||
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
writer.write(d + "-->" + tp.toString() + "\n");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<TrainPosition> query(List<TrainPosition> list, List<String> groups, Section.SectionRoadType roadType){
|
||||
List<TrainPosition> newList = list.stream().filter(d->groups.contains(d.getGroupNum()) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
public List<TrainPosition> query(List<TrainPosition> list, String groupNum, Section.SectionRoadType roadType){
|
||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
public List<TrainPosition> query(List<TrainPosition> list,String groupNum){
|
||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载json源文件
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public List<TrainPosition> readSource(String file){
|
||||
List<TrainPosition> list = Lists.newArrayList();
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))){
|
||||
String content;
|
||||
while((content = reader.readLine()) != null){
|
||||
TrainPosition tp = JsonUtils.read(content, TrainPosition.class);
|
||||
list.add(tp);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载日志
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public List<TrainPosition> readFile(String file) {
|
||||
|
||||
List<TrainPosition> list = Lists.newArrayList();
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))){
|
||||
String content;
|
||||
while((content = reader.readLine()) != null){
|
||||
if(content.indexOf("TrainPositionService ") >= 0){
|
||||
TrainPosition tp = parseString(content);
|
||||
if(Objects.nonNull(tp)){
|
||||
list.add(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
private TrainPosition parseString(String d){
|
||||
if(!d.contains("未找到")){
|
||||
String t = d.substring(0,19);
|
||||
int start = d.indexOf("{");
|
||||
String json = d.substring(start);
|
||||
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
|
||||
return tp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -267,7 +267,8 @@ public class TreeNode {
|
||||
if (!CollectionUtils.isEmpty(mapSystemVOList)) {
|
||||
Map<String, List<MapSystemVO>> listMap = mapSystemVOList.stream()
|
||||
.filter(mapSystemVO -> mapSystemVO.getMapId().equals(mapVO.getId())
|
||||
&& !MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType()))
|
||||
&& !MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
|
||||
&& !MapPrdTypeEnum.YJDDZH.getCode().equals(mapSystemVO.getPrdType()))
|
||||
.collect(Collectors.groupingBy(MapSystemVO::getType));
|
||||
listMap.forEach((type, list) -> {
|
||||
TreeNode systemNode = buildSystemNode(type, "");
|
||||
@ -275,7 +276,8 @@ public class TreeNode {
|
||||
list.forEach(mapSystemVO -> systemNode.addChild(buildMapSystemNode(mapSystemVO)));
|
||||
});
|
||||
List<MapSystemVO> collect = mapSystemVOList.stream()
|
||||
.filter(mapSystemVO -> MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
|
||||
.filter(mapSystemVO -> (MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
|
||||
|| MapPrdTypeEnum.YJDDZH.getCode().equals(mapSystemVO.getPrdType()))
|
||||
&& mapSystemVO.getMapId().equals(mapVO.getId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(collect)) {
|
||||
|
@ -7,7 +7,10 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum WebSocketMessageType {
|
||||
|
||||
/**
|
||||
* 应急调度指挥系统 返回前端的数据
|
||||
*/
|
||||
YJDDZH_TRAIN_POSITION,
|
||||
/**
|
||||
* 订单支付结果
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@ import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.groups.Default;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -19,6 +20,9 @@ import java.util.stream.Collectors;
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
public class AudioResourcesVO {
|
||||
public interface Create extends Default {}
|
||||
public interface Generate extends Default{}
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@ -29,14 +33,15 @@ public class AudioResourcesVO {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* 描述;生成时为语音内容
|
||||
*/
|
||||
@NotBlank(message = "描述不能为空", groups = Generate.class)
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 资源地址
|
||||
*/
|
||||
@NotBlank(message = "地址不能为空")
|
||||
@NotBlank(message = "地址不能为空", groups = {Create.class})
|
||||
private String url;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
@ -65,26 +65,27 @@ public class SocketMessageFactory {
|
||||
private static List<String> getTopicsBy(WebSocketMessageType messageType, String group) {
|
||||
List<String> topicList = new ArrayList<>();
|
||||
switch (messageType) {
|
||||
case YJDDZH_TRAIN_POSITION:{
|
||||
topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.getDestPattern());
|
||||
break;
|
||||
}
|
||||
case BROADCAST:
|
||||
case Order_Pay_Result:
|
||||
case JointTraining_Room_Invite:
|
||||
case Be_Logged_Out: {
|
||||
case Be_Logged_Out:
|
||||
case Simulation_Invite: {
|
||||
topicList.add(WebSocketSubscribeTopic.Common);
|
||||
break;
|
||||
}
|
||||
case JointTraining_Room:
|
||||
case JointTraining_Device:
|
||||
case JointTraining_Chat: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Room, group));
|
||||
topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case JointTraining_User: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Room, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
|
||||
break;
|
||||
}
|
||||
case Simulation_Invite: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Common));
|
||||
topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Simulation_Time_Sync:
|
||||
@ -109,7 +110,7 @@ public class SocketMessageFactory {
|
||||
case Competition_Practical:
|
||||
case SIMULATION_RAIL_TICKET:
|
||||
case Simulation_Alarm: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
|
||||
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case SIMULATION_RAILWAY_RUN_PLAN_SEND: // 铁路局运行计划下发
|
||||
@ -144,7 +145,12 @@ public class SocketMessageFactory {
|
||||
case Simulation_Script_Action:
|
||||
case Simulation_Driver_Change:
|
||||
case Simulation_TrainSpeed:
|
||||
case Simulation_Drive_Data_Routing:
|
||||
case Simulation_Drive_Data_Routing:{
|
||||
topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
// 20220819
|
||||
case Simulation_Training_Step_Tip:
|
||||
case Simulation_Training_Step_Finish:
|
||||
@ -173,44 +179,44 @@ public class SocketMessageFactory {
|
||||
case Device_Fault_Over_3D:
|
||||
case VR_Sync_3D:
|
||||
case SJL3D_TrainStatus: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
|
||||
topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Device_Load_Destroy_3D:
|
||||
case DeviceCtrl_3D:
|
||||
case TDT_3D:
|
||||
case BeAbout2Arrive_3D: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
|
||||
topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Train_Position_3D:
|
||||
case Train_Hmi_3D:
|
||||
case Train_Position: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
|
||||
topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case SDC:
|
||||
case SDSQ:
|
||||
case TPM: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.WeiAngU3dSimulation, group));
|
||||
topicList.add(SimulationSubscribeTopic.Wgu3d.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Simulation_Reset: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
|
||||
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.PassengerFlow.buildDestination(group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.WeiAngU3dSimulation, group));
|
||||
topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.Wgu3d.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Simulation_Over: {
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
|
||||
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.PassengerFlow.buildDestination(group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
|
||||
topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
|
||||
topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
|
||||
topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
|
||||
}
|
||||
}
|
||||
return topicList;
|
||||
@ -280,8 +286,8 @@ public class SocketMessageFactory {
|
||||
ConversationSocketMessageVO.buildExitMessage(conversation, member));
|
||||
}
|
||||
|
||||
public static SocketMessageVO<Integer> buildSimulationTimeSyncMessage(Simulation simulation) {
|
||||
int systemTime = simulation.getCorrectSystemTime().toLocalTime().toSecondOfDay();
|
||||
public static SocketMessageVO<Long> buildSimulationTimeSyncMessage(Simulation simulation) {
|
||||
long systemTime = simulation.getCorrectSystemTimeStamp();
|
||||
return build(WebSocketMessageType.Simulation_Time_Sync, simulation.getId(), systemTime);
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,13 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConf
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdIbpConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPsdConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig;
|
||||
@ -136,6 +137,9 @@ public class ProjectDeviceVO {
|
||||
case IBP:
|
||||
list.add(new HhcjIbpConfig(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new HhcjPsdConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
|
@ -532,6 +532,16 @@ public class HhcjIbpConfigVO extends RealConfigVO {
|
||||
*/
|
||||
private Integer w_sdtf_cthbm11M10 = 140;
|
||||
|
||||
/**
|
||||
* 屏蔽门-实体-开门
|
||||
*/
|
||||
private Integer w_psd_real_km = 144;
|
||||
|
||||
/**
|
||||
* 屏蔽门-实体-关门
|
||||
*/
|
||||
private Integer w_psd_real_gm = 145;
|
||||
|
||||
/**
|
||||
* 车站环控-恢复正常按钮
|
||||
*/
|
||||
@ -959,6 +969,11 @@ public class HhcjIbpConfigVO extends RealConfigVO {
|
||||
*/
|
||||
private Integer w_xfsb_dsw = 292;
|
||||
|
||||
/**
|
||||
* 闸机-实体设备控制
|
||||
*/
|
||||
private Integer w_zj_real = 296;
|
||||
|
||||
public HhcjIbpConfigVO() {
|
||||
super(0, 304);
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package club.joylink.rtss.vo.client.project.hhcj;
|
||||
|
||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class HhcjPsdConfigVO extends RealConfigVO {
|
||||
private String psdCode = "Psd87821";
|
||||
|
||||
/**
|
||||
* PLC网关的144
|
||||
*/
|
||||
private Integer w_km = 144;
|
||||
|
||||
/**
|
||||
* PLC网关的145
|
||||
*/
|
||||
private Integer w_gm = 145;
|
||||
|
||||
public HhcjPsdConfigVO() {
|
||||
super(0, 304);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package club.joylink.rtss.vo.client.user;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 找回密码
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class RetrievePwdVO {
|
||||
private String mobile;
|
||||
|
||||
private String email;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String vfCode;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String newPwd;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.vo.client.user;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -9,6 +10,7 @@ import javax.validation.constraints.NotBlank;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UpdatePasswordVO {
|
||||
/**
|
||||
* 短信验证码
|
||||
|
@ -1,18 +1,60 @@
|
||||
package club.joylink.rtss.vo.ws;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
||||
public class TrainPosition {
|
||||
private String trainTripNum;
|
||||
private String groupNum;
|
||||
/**
|
||||
* 方向1=上行(向右),0=下行(向左)
|
||||
*/
|
||||
private int direction;
|
||||
/**
|
||||
* 公里标
|
||||
*/
|
||||
private float location;
|
||||
/**
|
||||
* 数据接受时间
|
||||
*/
|
||||
private Long receiveTime;
|
||||
/**
|
||||
* 对应所在区段code
|
||||
*/
|
||||
private String sectionCode;
|
||||
|
||||
/**
|
||||
* 是否到站
|
||||
*/
|
||||
// private boolean arrive;
|
||||
|
||||
/**
|
||||
* 启动
|
||||
*/
|
||||
// private boolean startover;
|
||||
/**
|
||||
* 离开
|
||||
*/
|
||||
// private boolean leave;
|
||||
/**
|
||||
* 是否开门
|
||||
*/
|
||||
private boolean closeDoor;
|
||||
/**
|
||||
* 是否停稳
|
||||
*/
|
||||
private boolean stop;
|
||||
|
||||
|
||||
public Section.SectionRoadType getRoadType(){
|
||||
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
|
||||
@ -24,4 +66,15 @@ public class TrainPosition {
|
||||
public boolean isRight(){
|
||||
return this.direction == 1;
|
||||
}
|
||||
|
||||
public String dateFormat(){
|
||||
Instant instant = Instant.ofEpochMilli(this.receiveTime);
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
return LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
return JsonUtils.writeValueNullableFieldAsString(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.DestinationVariable;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -36,7 +37,9 @@ public class WebSocketController {
|
||||
}
|
||||
|
||||
@MessageMapping("/{mapName}/trainPosition")
|
||||
// @SendTo("/topic/trainPosition")
|
||||
public void mlbs( String json,@DestinationVariable String mapName) {
|
||||
this.trainPositionService.initTrainOrUpdate(mapName,json);
|
||||
// return json;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package club.joylink.rtss.websocket;
|
||||
|
||||
import club.joylink.rtss.services.LoginSessionManager;
|
||||
import club.joylink.rtss.services.SysUserService;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.websocket.interceptor.PresenceChannelInterceptor;
|
||||
import club.joylink.rtss.websocket.interceptor.SessionAuthHandshakeInterceptor;
|
||||
import club.joylink.rtss.websocket.interceptor.VSimpleInterceptor;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -15,6 +20,7 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.security.Principal;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -25,7 +31,10 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Autowired
|
||||
private LoginSessionManager loginSessionManager;
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private PresenceChannelInterceptor presenceChannelInterceptor;
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
@ -43,11 +52,13 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
registry.addEndpoint("/joylink-websocket")
|
||||
.addInterceptors(new SessionAuthHandshakeInterceptor(loginSessionManager))
|
||||
.setHandshakeHandler(new DefaultHandshakeHandler() {
|
||||
|
||||
@Override
|
||||
protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
|
||||
Map<String, Object> attributes) {
|
||||
return new MyPrincipal((LoginUserInfoVO) attributes.get(SessionAuthHandshakeInterceptor.ATTR_USER_KEY));
|
||||
}
|
||||
|
||||
})
|
||||
.setAllowedOrigins("*");
|
||||
registry.addEndpoint("/joylink-wm-websocket")
|
||||
@ -63,6 +74,16 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
})
|
||||
.setAllowedOrigins("*");
|
||||
registry.addEndpoint("/joylink-tbi-websocket")
|
||||
.addInterceptors(new VSimpleInterceptor(this.sysUserService))
|
||||
.setHandshakeHandler(new DefaultHandshakeHandler() {
|
||||
|
||||
@Override
|
||||
protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
|
||||
Map<String, Object> attributes) {
|
||||
return new TrainPositionPrincipal((AccountVO) attributes.get(VSimpleInterceptor.ATT_USER_KEY));
|
||||
}
|
||||
|
||||
})
|
||||
.setAllowedOrigins("*");
|
||||
}
|
||||
|
||||
@ -107,4 +128,20 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
}
|
||||
|
||||
}
|
||||
@Getter
|
||||
public class TrainPositionPrincipal implements Principal {
|
||||
|
||||
private AccountVO user;
|
||||
|
||||
public TrainPositionPrincipal(AccountVO user) {
|
||||
Objects.requireNonNull(user, "用户不能为null");
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.user.getMobile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package club.joylink.rtss.websocket.client;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
|
||||
import club.joylink.rtss.util.test.LogTest;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.messaging.simp.stomp.StompSession;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
@ -9,7 +14,12 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -24,21 +34,56 @@ public class StompClientManager {
|
||||
WebSocketStompClient stompClient = new WebSocketStompClient(socketClient);
|
||||
SimulationSessionHandler handler = new SimulationSessionHandler();
|
||||
ListenableFuture<StompSession> future = stompClient
|
||||
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
|
||||
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket?user_account=train_place&account_pwd=train_place",handler, "null");
|
||||
StompSession stompSession = future.get();
|
||||
LogTest lt = new LogTest();
|
||||
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
||||
// List<TrainPosition> list = lt.readSource("d:\\t.txt");
|
||||
// runToLeft(stompSession,"001");
|
||||
// runToRight(stompSession,"002");
|
||||
list = lt.query(list,"004",Section.SectionRoadType.LEFT);
|
||||
// list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT);
|
||||
send(stompSession,list);
|
||||
}
|
||||
|
||||
runToLeft(stompSession,"train001");
|
||||
// runToRight(stompSession,"train002");
|
||||
public static void send(StompSession stompSession,List<TrainPosition> list){
|
||||
|
||||
// for (int i = 25; i < list.size(); i++) {
|
||||
for (int i = 22; i < 23; i++) {
|
||||
TrainPosition tp = list.get(i);
|
||||
tp.setCloseDoor(false);
|
||||
tp.setStop(false);
|
||||
// tp.setLocation(tp.getLocation() - 500);
|
||||
String val = JsonUtils.writeValueNullableFieldAsString(tp);
|
||||
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
System.out.println(d + " ->" + i +" ->" + val);
|
||||
stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
if(i > 0){
|
||||
TrainPosition old = list.get(i - 1);
|
||||
try {
|
||||
long sleepTime = (tp.getReceiveTime() - old.getReceiveTime());
|
||||
if(sleepTime > 10000){
|
||||
sleepTime = sleepTime / 1000;
|
||||
}
|
||||
System.out.println("index:" + i + "sleep:"+sleepTime);
|
||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void runToLeft(StompSession stompSession,String tripNum){
|
||||
int step = 80;
|
||||
int step = 20;
|
||||
int location = 40000;
|
||||
while(true){
|
||||
location -= step;
|
||||
Map<String,Object> dataMap = new HashMap<>();
|
||||
dataMap.put("trainTripNum",tripNum);
|
||||
dataMap.put("groupNum",tripNum);
|
||||
// dataMap.put("direction",1);
|
||||
dataMap.put("direction",0);
|
||||
dataMap.put("location",location);
|
||||
@ -58,7 +103,7 @@ public class StompClientManager {
|
||||
while(true){
|
||||
location += step;
|
||||
Map<String,Object> dataMap = new HashMap<>();
|
||||
dataMap.put("trainTripNum",tripNum);
|
||||
dataMap.put("groupNum",tripNum);
|
||||
dataMap.put("direction",1);
|
||||
// dataMap.put("direction",0);
|
||||
dataMap.put("location",location);
|
||||
|
@ -0,0 +1,59 @@
|
||||
package club.joylink.rtss.websocket.client;
|
||||
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.util.test.LogTest;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.messaging.simp.stomp.StompFrameHandler;
|
||||
import org.springframework.messaging.simp.stomp.StompHeaders;
|
||||
import org.springframework.messaging.simp.stomp.StompSession;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public class StompClientManager2 {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
StandardWebSocketClient socketClient = new StandardWebSocketClient();
|
||||
WebSocketStompClient stompClient = new WebSocketStompClient(socketClient);
|
||||
SimulationSessionHandler handler = new SimulationSessionHandler();
|
||||
ListenableFuture<StompSession> future = stompClient
|
||||
.connect("ws://127.0.0.1:9000/joylink-websocket?token=6a8dbf62d3683844a6aa722b73b989f1",handler, "null");
|
||||
StompSession stompSession = future.get();
|
||||
stompSession.subscribe("/topic/yjddzh/trainPosition", new StompFrameHandler() {
|
||||
@Override
|
||||
public Type getPayloadType(StompHeaders stompHeaders) {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleFrame(StompHeaders stompHeaders, Object o) {
|
||||
String recv=null;
|
||||
try {
|
||||
recv = new String((byte[]) o,"UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(recv);
|
||||
}
|
||||
});
|
||||
stompSession.setAutoReceipt(true);
|
||||
TimeUnit.SECONDS.sleep(100);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package club.joylink.rtss.websocket.interceptor;
|
||||
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseInterceptor implements HandshakeInterceptor {
|
||||
@Override
|
||||
public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map<String, Object> map) throws Exception {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Exception e) {
|
||||
|
||||
}
|
||||
|
||||
public Map<String,String> findQueryParams( ServerHttpRequest request){
|
||||
String query = request.getURI().getQuery();
|
||||
Map<String, String> map = buildQueryMap(query);
|
||||
return map;
|
||||
}
|
||||
private Map<String, String> buildQueryMap(String query) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (StringUtils.hasText(query)) {
|
||||
String[] splits = query.split("&");
|
||||
for (int i = 0; i < splits.length; ++i) {
|
||||
String temp = splits[i];
|
||||
int index = temp.indexOf("=");
|
||||
if (index >= 0) {
|
||||
String key = temp.substring(0, index);
|
||||
String val = temp.substring(index + 1);
|
||||
map.put(key, val);
|
||||
} else {
|
||||
map.put(temp, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package club.joylink.rtss.websocket.interceptor;
|
||||
|
||||
import club.joylink.rtss.websocket.WebsocketConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PresenceChannelInterceptor implements ChannelInterceptor {
|
||||
|
||||
@Override
|
||||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
|
||||
StompHeaderAccessor sha = StompHeaderAccessor.wrap(message);
|
||||
if(Objects.isNull(sha.getCommand())) {
|
||||
return;
|
||||
}
|
||||
Principal principal = sha.getUser();
|
||||
// log.info(" STOMP " + sha.getCommand());
|
||||
String wsSessionId = sha.getSessionId();
|
||||
String dest = sha.getDestination();
|
||||
|
||||
switch(sha.getCommand()) {
|
||||
// case SUBSCRIBE:
|
||||
// case UNSUBSCRIBE:
|
||||
case DISCONNECT:
|
||||
this.unregister(wsSessionId,dest,principal);
|
||||
break;
|
||||
case CONNECT:
|
||||
case CONNECTED:
|
||||
this.register(wsSessionId,dest,principal);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void register(String wsSessionId, String destination, Principal principal) {
|
||||
if(Objects.equals(false,principal instanceof WebsocketConfig.TrainPositionPrincipal)){
|
||||
return;
|
||||
}
|
||||
log.info("武汉8号线 创建stmop链接name:{}",principal.getName());
|
||||
}
|
||||
|
||||
|
||||
private void unregister(String wsSessionId, String destination, Principal principal) {
|
||||
if(Objects.equals(false,principal instanceof WebsocketConfig.TrainPositionPrincipal)){
|
||||
return;
|
||||
}
|
||||
log.info("武汉8号线 关闭stmop链接name:{}",principal.getName());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.websocket;
|
||||
package club.joylink.rtss.websocket.interceptor;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.LoginSessionManager;
|
||||
@ -15,7 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
|
||||
public class SessionAuthHandshakeInterceptor extends BaseInterceptor {
|
||||
private static final String Token_Key = "token";
|
||||
public static final String ATTR_USER_KEY = "user";
|
||||
private LoginSessionManager loginSessionManager;
|
||||
@ -39,9 +39,9 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
|
||||
}
|
||||
|
||||
private LoginUserInfoVO getLoginUser(ServerHttpRequest request) {
|
||||
String query = request.getURI().getQuery();
|
||||
Map<String, String> map = buildQueryMap(query);
|
||||
log.info(String.format("webSocket handshake query: [%s]", query));
|
||||
// String query = request.getURI().getQuery();
|
||||
Map<String, String> map = this.findQueryParams(request);
|
||||
log.info(String.format("webSocket handshake query: [%s]", map));
|
||||
BusinessExceptionAssertEnum.NOT_LOGIN.assertTrue(StringUtils.hasText(map.get(Token_Key)));
|
||||
return this.loginSessionManager.getLoginInfoByToken(map.get(Token_Key));
|
||||
// AccountVO accountVO = loginInfoVO.getAccountVO();
|
||||
@ -49,28 +49,4 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
|
||||
// return accountVO;
|
||||
}
|
||||
|
||||
private Map<String, String> buildQueryMap(String query) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (StringUtils.hasText(query)) {
|
||||
String[] splits = query.split("&");
|
||||
for (int i = 0; i < splits.length; ++i) {
|
||||
String temp = splits[i];
|
||||
int index = temp.indexOf("=");
|
||||
if (index >= 0) {
|
||||
String key = temp.substring(0, index);
|
||||
String val = temp.substring(index + 1);
|
||||
map.put(key, val);
|
||||
} else {
|
||||
map.put(temp, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
|
||||
Exception exception) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package club.joylink.rtss.websocket.interceptor;
|
||||
|
||||
import club.joylink.rtss.constants.Project;
|
||||
import club.joylink.rtss.services.SysUserService;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class VSimpleInterceptor extends BaseInterceptor {
|
||||
private SysUserService sysUserService;
|
||||
|
||||
public VSimpleInterceptor(SysUserService sysUserService) {
|
||||
this.sysUserService = sysUserService;
|
||||
}
|
||||
|
||||
|
||||
public final static String ATT_USER_KEY = "userVo";
|
||||
@Override
|
||||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map<String, Object> attributes) throws Exception {
|
||||
Map<String, String> map = this.findQueryParams(request);
|
||||
log.info(String.format("webSocket handshake query: [%s]", map));
|
||||
try{
|
||||
AccountVO vo = this.checkUserInfo(map);
|
||||
if(Objects.isNull(vo)){
|
||||
return false;
|
||||
}
|
||||
attributes.put(ATT_USER_KEY,vo);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final static String USER_ACCOUNT = "user_account";
|
||||
private final static String ACCOUNT_PWD = "account_pwd";
|
||||
private AccountVO checkUserInfo(Map<String,String> dataMap){
|
||||
AccountVO vo = this.sysUserService.findUserByAccountAndPassword(dataMap.get(USER_ACCOUNT),dataMap.get(ACCOUNT_PWD), Project.DEFAULT);
|
||||
return vo;
|
||||
}
|
||||
}
|
@ -24,8 +24,8 @@ spring:
|
||||
mail:
|
||||
host: smtp.exmail.qq.com
|
||||
port: 465
|
||||
username: ServiceEmail@joylink.club
|
||||
password: wFHcZQFuigKPvpSr
|
||||
username: serviceemai@joylink.club
|
||||
password: Jiulian0503
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
@ -190,9 +190,9 @@ common:
|
||||
spring:
|
||||
profiles: local
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://192.168.0.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: joylink0503
|
||||
password: localdb
|
||||
|
||||
tencent-cloud:
|
||||
allow-send: false
|
||||
|
Loading…
Reference in New Issue
Block a user