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

This commit is contained in:
walker-sheng 2021-03-26 17:08:39 +08:00
commit 40956d2c52
24 changed files with 295 additions and 737 deletions

View File

@ -159,16 +159,16 @@ public class OrgController {
return iOrgUserService.getUserCompanyDeparts(user, companyId);
}
@ApiOperation("查询组织(班级)的课")
@ApiOperation("查询自己给该组织(班级)的课")
@GetMapping("/orgLesson/{orgId}/list")
public List<LessonVO> queryOrgLesson(@PathVariable Long orgId) {
return iOrgLessonService.queryOrgLesson(orgId);
public List<LessonVO> queryOrgLessonICreated(@PathVariable Long orgId, @RequestAttribute UserVO user) {
return iOrgLessonService.queryOrgLessonICreated(orgId, user);
}
@ApiOperation("修改班级-课程关系")
@PutMapping("/orgLesson/{clsId}/update")
public void updateOrgLesson(@PathVariable Long clsId, @RequestBody List<Long> lessonIds, @RequestAttribute UserVO user) {
iOrgLessonService.updateOrgLesson(clsId, lessonIds, user);
public void updateOrgLesson(@PathVariable Long clsId, @RequestBody List<Long> lessonIds, @RequestAttribute LoginUserInfoVO loginInfo) {
iOrgLessonService.updateOrgLesson(clsId, lessonIds, loginInfo);
}
@ApiOperation("给班级添加学生")

View File

@ -164,9 +164,9 @@ public class RunPlanDraftController {
}
@ApiOperation(value = "根据用户交路查询交路区段列表")
@GetMapping(path = "/{planId}/{routingCode}/userRoutingSectionList")
public List<RunPlanRoutingSection> getRoutingSectionList(@PathVariable Long planId, @PathVariable String routingCode, @ApiIgnore @RequestAttribute UserVO user) {
return this.iRunPlanRoutingService.getRoutingSectionDataBy(user.getId() , planId, routingCode);
@GetMapping(path = "/{routingCode}/routingSectionList")
public List<RunPlanRoutingSection> getRoutingSectionList( @PathVariable Long routingCode, @ApiIgnore @RequestAttribute UserVO user) {
return this.iRunPlanRoutingService.getRoutingSectionDataBy(user.getId() , routingCode);
}
@ApiOperation(value = "增加计划")

View File

@ -67,7 +67,7 @@ public interface UserTrainingStatsMapper {
"ut.user_id AS userId " +
"FROM user_training_stats ut " +
"LEFT JOIN sys_user u ON u.id = ut.user_id " +
"WHERE u.id = #{userId} AND finishTime &gt; #{startTime} AND finishTime &lt; #{endTime} " +
"WHERE u.id = #{userId} AND finishTime &gt;= #{startTime} AND finishTime &lt;= #{endTime} " +
"AND ut.lesson_id IN" +
"<foreach collection='lessonIds' item='lessonId' open='(' separator=',' close=')'>" +
"#{lessonId}" +

View File

@ -622,8 +622,13 @@ public class ExamService implements IExamService {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
if (queryVO.isSelf()) {
criteria.andCreatorIdEqualTo(loginInfo.getUserVO().getId());
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(UserVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(creatorIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<ExamDefinition> page = (Page<ExamDefinition>) examDefinitionDAO.selectByExample(example);
@ -647,7 +652,7 @@ public class ExamService implements IExamService {
List<Long> clsIds = clsList.stream().map(Org::getId).collect(Collectors.toList());
lessonIds = iOrgLessonService.findEntitiesByOrgIds(clsIds).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
} else {
lessonIds = iOrgLessonService.findEntitiesByOrgId(clsId).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
lessonIds = iOrgLessonService.findEntitiesByOrgId(clsId, null).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
}
return findEntityByLessonIdList(lessonIds).stream()
.filter(exam -> loginInfo.getUserVO().getId().equals(exam.getCreatorId()))

View File

@ -222,7 +222,8 @@ public class LessonService implements ILessonService {
// MapVO mapVO = iMapService.findMapBaseInfoById(publishVO.getMapId());
// BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(publishVO.getPrdType());
// String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.getName());
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(publishVO.isCoverSameNameLesson(),
"与已有课程同名,请修改名称");
LessonVO sysFaultLesson = findSysFaultByMapAndPrdType(publishVO.getMapId(), publishVO.getPrdType());
if (sysFaultLesson != null) {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(Objects.equals(publishVO.getName(), sysFaultLesson.getName()), "与系统默认课程重名,请修改名称");
@ -387,13 +388,17 @@ public class LessonService implements ILessonService {
@Override
public List<LessonVO> queryByIds(List<Long> lessonIds, String status) {
LsLessonExample lessonExample = new LsLessonExample();
Criteria criteria = lessonExample.createCriteria().andIdIn(lessonIds);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
if (CollectionUtils.isEmpty(lessonIds)) {
return new ArrayList<>();
} else {
LsLessonExample lessonExample = new LsLessonExample();
Criteria criteria = lessonExample.createCriteria().andIdIn(lessonIds);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
List<LsLesson> lessonList = this.lessonDAO.selectByExample(lessonExample);
return LessonVO.convert(lessonList);
}
List<LsLesson> lessonList = this.lessonDAO.selectByExample(lessonExample);
return LessonVO.convert(lessonList);
}
@Override
@ -561,19 +566,25 @@ public class LessonService implements ILessonService {
@Override
public PageVO<LessonVO> pagedQueryByLoginProject(LessonQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<MapVO> maps = iMapService.findOnlineMapByProjectCode(loginInfo.getProject().name());
PageVO<LessonVO> defaultPageVO = new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
if (CollectionUtils.isEmpty(maps)) {
return new PageVO<>();
return defaultPageVO;
} else {
List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList());
LsLessonExample example = new LsLessonExample();
Criteria criteria = example.createCriteria();
criteria.andMapIdIn(mapIds).andSysfaultEqualTo(false);
if (queryVO.isSelf()) {
criteria.andCreatorIdEqualTo(loginInfo.getUserVO().getId());
}
criteria.andMapIdIn(mapIds).andSysfaultEqualTo(false).andStatusEqualTo(BusinessConsts.STATUS_USE);
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(UserVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(creatorIds)) {
return defaultPageVO;
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<LsLesson> page = (Page<LsLesson>) lessonDAO.selectByExample(example);
Map<Long, SysUser> creators = iSysUserService.findEntity(page.stream().map(LsLesson::getCreatorId).collect(Collectors.toList()), null)
@ -585,16 +596,12 @@ public class LessonService implements ILessonService {
@Override
public List<LessonVO> queryByLoginProject(LessonQueryVO queryVO, LoginUserInfoVO loginInfo) {
if (queryVO.isSelf()) {
return queryNonDefaultLessons(loginInfo.getUserVO().getId(), loginInfo.getProject(), BusinessConsts.STATUS_USE);
} else {
return queryNonDefaultLessons(null, loginInfo.getProject(), BusinessConsts.STATUS_USE);
}
return queryNonDefaultLessons(null, loginInfo.getProject(), BusinessConsts.STATUS_USE);
}
@Override
public List<LessonVO> queryOrgLessonOfSelf(Long clsId, LoginUserInfoVO loginInfo) {
List<Long> lessonIds = iOrgLessonService.findEntitiesByOrgId(clsId).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
List<Long> lessonIds = iOrgLessonService.findEntitiesByOrgId(clsId, null).stream().map(OrgLesson::getLessonId).collect(Collectors.toList());
List<LsLesson> lessonEntities = findLessonEntities(lessonIds);
return lessonEntities.stream()
.filter(lesson -> loginInfo.getUserVO().getId().equals(lesson.getCreatorId())).map(LessonVO::new).collect(Collectors.toList());
@ -610,6 +617,7 @@ public class LessonService implements ILessonService {
LsLessonExample example = new LsLessonExample();
Criteria criteria = example.createCriteria()
.andMapIdIn(mapIds)
.andStatusEqualTo(BusinessConsts.STATUS_USE)
.andSysfaultEqualTo(false);
if (creatorId != null) {
criteria.andCreatorIdEqualTo(creatorId);

View File

@ -1,8 +1,12 @@
package club.joylink.rtss.services;
import club.joylink.rtss.constants.*;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.constants.MapSystemType;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.constants.StatusEnum;
import club.joylink.rtss.dao.MapSystemDAO;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.entity.MapSystem;
import club.joylink.rtss.entity.MapSystemExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.org.IOrgLessonService;
import club.joylink.rtss.services.org.IOrgService;
@ -27,10 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@Service
@ -221,30 +223,30 @@ public class MapSystemService implements IMapSystemService {
mapSystemDetailVO.setPermissionList(permissionVOList);
} else if (MapSystemType.Lesson.name().equals(mapSystem.getType()) || MapSystemType.Exam.name().equals(mapSystem.getType())) {
Org topOrg = iOrgService.findEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
// Org topOrg = iOrgService.findEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
List<LessonVO> lessonVOList;
if (!Project.CGY.equals(loginInfo.getProject()) && topOrg != null) { //由于成都工业的特殊性先防一下
lessonVOList = new ArrayList<>();
LessonVO defaultLesson = iLessonService.findSysFaultByMapAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
if (defaultLesson != null && MapStatus.Online.getCode().equals(defaultLesson.getStatus())) {
lessonVOList.add(defaultLesson);
}
List<LessonVO> lessonsICreated = iLessonService.queryNonDefaultLessons(loginInfo.getUserVO().getId(),
loginInfo.getProject(), BusinessConsts.STATUS_USE);
lessonVOList.addAll(lessonsICreated);
//如果当前用户有所属班级查询所属有效班级关联的有效课程
List<OrgUser> orgUsers = iOrgUserService.findEntities(loginInfo.getUserVO().getId(), null);
List<Long> orgIds = orgUsers.stream().map(OrgUser::getOrgId).collect(Collectors.toList());
List<Long> validOrgIds = iOrgService.findEntities(orgIds, BusinessConsts.Org.Status.VALID)
.stream().map(Org::getId).collect(Collectors.toList());
Set<Long> lessonIdSet = lessonVOList.stream().map(LessonVO::getId).collect(Collectors.toSet());
List<Long> orgLessonIds = iOrgLessonService.findEntitiesByOrgIds(validOrgIds).stream().map(OrgLesson::getLessonId)
.filter(lessonId -> !lessonIdSet.contains(lessonId)).distinct().collect(Collectors.toList());
lessonVOList.addAll(iLessonService.queryByIds(orgLessonIds, BusinessConsts.STATUS_USE));
//
} else {
// if (!Project.CGY.equals(loginInfo.getProject()) && topOrg != null) { //由于成都工业的特殊性先防一下
// lessonVOList = new ArrayList<>();
// LessonVO defaultLesson = iLessonService.findSysFaultByMapAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
// if (defaultLesson != null && MapStatus.Online.getCode().equals(defaultLesson.getStatus())) {
// lessonVOList.add(defaultLesson);
// }
// List<LessonVO> lessonsICreated = iLessonService.queryNonDefaultLessons(loginInfo.getUserVO().getId(),
// loginInfo.getProject(), BusinessConsts.STATUS_USE);
// lessonVOList.addAll(lessonsICreated);
// //如果当前用户有所属班级查询所属有效班级关联的有效课程
// List<OrgUser> orgUsers = iOrgUserService.findEntities(loginInfo.getUserVO().getId(), null);
// List<Long> orgIds = orgUsers.stream().map(OrgUser::getOrgId).collect(Collectors.toList());
// List<Long> validOrgIds = iOrgService.findEntities(orgIds, BusinessConsts.Org.Status.VALID)
// .stream().map(Org::getId).collect(Collectors.toList());
// Set<Long> lessonIdSet = lessonVOList.stream().map(LessonVO::getId).collect(Collectors.toSet());
// List<Long> orgLessonIds = iOrgLessonService.findEntitiesByOrgIds(validOrgIds).stream().map(OrgLesson::getLessonId)
// .filter(lessonId -> !lessonIdSet.contains(lessonId)).distinct().collect(Collectors.toList());
// lessonVOList.addAll(iLessonService.queryByIds(orgLessonIds, BusinessConsts.STATUS_USE));
// //
// } else {
lessonVOList = iLessonService.getByMapIdAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType());
}
// }
if (CollectionUtils.isEmpty(lessonVOList)) {
return mapSystemDetailVO;

View File

@ -791,11 +791,38 @@ public class RunPlanDraftService implements IRunPlanDraftService {
errorList.add("运行图数据为空!");
return errorList;
}
// 找到每个服务发车时间查找发车时间不能过早 结束时间不能过晚
// 同一服务 根据发车排序每个车次往后每个时刻应该晚于上个且时刻之间时间应该根据站间运行等级距离计算最小值
// 不同服务发车间隔>=1分45秒
// 同站车次间隔时间不能过小 根据最大最小速度计算 站间距离
// 折返时间
// Map<String, List<RunPlanImport>> serviceNumberMap = runPlanImportList.stream()
// .collect(Collectors.groupingBy(RunPlanImport::getServiceNumber, LinkedHashMap::new, Collectors.toList()));
// serviceNumberMap.forEach((serviceNumber, importList) -> {
// // 排序
// importList.sort(Comparator.comparing(runPlanImport -> runPlanImport.getArrivalList().get(0).getArriveTime()));
//
/* 找到每个服务发车时间查找发车时间不能过早 结束时间不能过晚
1 所有服务所有发车时间验证
2 不同服务同一站同向发车间隔验证>=1分45秒
*/
Map<String, List<RunPlanTripVO>> serviceMap = planVO.getTripList().stream().collect(Collectors.groupingBy(RunPlanTripVO::getServiceNumber));
serviceMap.forEach((s, runPlanTripVOS) -> {
runPlanTripVOS.forEach(runPlanTripVO -> {
List<RunPlanTripTimeVO> timeList = runPlanTripVO.getTimeList();
if (CollectionUtils.isEmpty(timeList)) {
errorList.add(String.format("服务号[%s]车次号[%s]没有到站时刻数据", s, runPlanTripVO.getTripNumber()));
return;
}
});
});
/* 同一服务 根据发车排序每个车次往后每个时刻应该晚于上个且时刻之间时间应该根据站间运行等级距离计算最小值
* 1 同一服务 每个车次 每个时刻停站时间 运行间隔 车次到下一车次是否衔接 折返时间
* */
// 同站相邻车次间隔时间不能过小 根据最大最小速度计算 站间距离
MapVO map = this.iMapService.getMapDetail(planVO.getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapData(map);

View File

@ -708,12 +708,16 @@ public class SysUserService implements ISysUserService {
@Override
public List<SysUser> findEntity(List<Long> ids, String orderBy) {
SysUserExample example = new SysUserExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
} else {
SysUserExample example = new SysUserExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
}
example.createCriteria().andIdIn(ids);
return sysUserDAO.selectByExample(example);
}
example.createCriteria().andIdIn(ids);
return sysUserDAO.selectByExample(example);
}
@Override

View File

@ -1,19 +1,21 @@
package club.joylink.rtss.services.org;
import club.joylink.rtss.entity.OrgLesson;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.LessonVO;
import java.util.List;
public interface IOrgLessonService {
void updateOrgLesson(Long clsId, List<Long> lessonIds, UserVO user);
void updateOrgLesson(Long clsId, List<Long> lessonIds, LoginUserInfoVO loginInfo);
/**
* 查询该组织的课程
* @param orgId
* @param user
*/
List<LessonVO> queryOrgLesson(Long orgId);
List<LessonVO> queryOrgLessonICreated(Long orgId, UserVO user);
/**
* 查询这些组织的课程关联关系
@ -25,5 +27,5 @@ public interface IOrgLessonService {
List<OrgLesson> findEntitiesByLessonId(Long lessonId);
List<OrgLesson> findEntitiesByOrgId(Long orgId);
List<OrgLesson> findEntitiesByOrgId(Long orgId, Long creatorId);
}

View File

@ -2,15 +2,19 @@ package club.joylink.rtss.services.org;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.OrgLessonDAO;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.OrgLesson;
import club.joylink.rtss.entity.OrgLessonExample;
import club.joylink.rtss.services.ILessonService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.LessonVO;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -26,26 +30,33 @@ public class OrgLessonService implements IOrgLessonService {
@Autowired
private ILessonService iLessonService;
@Autowired
private IOrgUserService iOrgUserService;
@Override
public void updateOrgLesson(Long clsId, List<Long> lessonIds, UserVO user) {
iOrgService.confirmExist(clsId);
//确认是该
public void updateOrgLesson(Long clsId, List<Long> lessonIds, LoginUserInfoVO loginInfo) {
//校验
Org topOrg = iOrgService.getTopOrgEntity(clsId, BusinessConsts.Org.Status.VALID);
Long userId = loginInfo.getUserVO().getId();
iOrgUserService.confirmIsTheRoleInThisOrg(userId, topOrg.getId(), BusinessConsts.OrgRole.Admin);
//删除该组织的所有旧数据
OrgLessonExample example = new OrgLessonExample();
example.createCriteria().andOrgIdEqualTo(clsId);
example.createCriteria().andOrgIdEqualTo(clsId).andCreatorIdEqualTo(userId);
orgLessonDAO.deleteByExample(example);
//添加新数据
lessonIds.forEach(lessonId -> {
OrgLesson orgLesson = new OrgLesson();
orgLesson.setLessonId(lessonId);
orgLesson.setOrgId(clsId);
orgLesson.setCreatorId(userId);
orgLesson.setCreateTime(LocalDateTime.now());
orgLessonDAO.insert(orgLesson);
});
}
@Override
public List<LessonVO> queryOrgLesson(Long orgId) {
List<OrgLesson> orgLessons = findEntitiesByOrgId(orgId);
public List<LessonVO> queryOrgLessonICreated(Long orgId, UserVO user) {
List<OrgLesson> orgLessons = findEntitiesByOrgId(orgId, user.getId());
if (CollectionUtils.isEmpty(orgLessons)) {
return new ArrayList<>();
} else {
@ -84,9 +95,12 @@ public class OrgLessonService implements IOrgLessonService {
}
@Override
public List<OrgLesson> findEntitiesByOrgId(Long orgId) {
public List<OrgLesson> findEntitiesByOrgId(@NonNull Long orgId, Long creatorId) {
OrgLessonExample example = new OrgLessonExample();
example.createCriteria().andOrgIdEqualTo(orgId);
OrgLessonExample.Criteria criteria = example.createCriteria().andOrgIdEqualTo(orgId);
if (creatorId != null) {
criteria.andCreatorIdEqualTo(creatorId);
}
return orgLessonDAO.selectByExample(example);
}
}

View File

@ -177,8 +177,25 @@ public class OrgService implements IOrgService {
}
@Override
public PageVO<DepartmentVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), queryVO.isSelf());
public PageVO<DepartmentVO> pagedQueryCls(@NonNull OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
Org topOrg = getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdEqualTo(topOrg.getId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
}
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(UserVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(creatorIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<Long> creatorIds = page.stream().map(Org::getCreatorId).collect(Collectors.toList());
@ -193,7 +210,16 @@ public class OrgService implements IOrgService {
@Override
public List<DepartmentVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
OrgExample example = buildQueryClsExample(queryVO, loginInfo.getUserVO().getId(), loginInfo.getProject(), queryVO.isSelf());
Org topOrg = getEntity(loginInfo.getProject(), BusinessConsts.Org.Status.VALID);
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdEqualTo(topOrg.getId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
}
List<Org> clsList = orgDAO.selectByExample(example);
return clsList.stream().map(DepartmentVO::new).collect(Collectors.toList());
}
@ -244,23 +270,6 @@ public class OrgService implements IOrgService {
return new CompanyVO(entity);
}
private OrgExample buildQueryClsExample(OrgQueryVO queryVO, Long userId, Project project, boolean self) {
Org topOrg = getEntity(project, BusinessConsts.Org.Status.VALID);
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdEqualTo(topOrg.getId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (self) {
criteria.andCreatorIdEqualTo(userId);
}
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
}
return example;
}
/**
* 创建非顶级组织
*/
@ -270,7 +279,7 @@ public class OrgService implements IOrgService {
//检查同级同名组织
List<Org> entities = findEntitiesByParentId(parentId, null, BusinessConsts.Org.Status.VALID);
if (!CollectionUtils.isEmpty(entities)) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)),
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)),
String.format("上级为[%s]的同名组织已存在", parentId));
}
//创建新组织

View File

@ -427,6 +427,11 @@ public class OrgUserService implements IOrgUserService {
confirmIsTheRoleInThisOrg(user.getId(), clsId, BusinessConsts.OrgRole.Teacher);
Org topOrg = iOrgService.getEntity(cls.getRootId());
Set<Long> studentIdSet = findEntitiesByOrgId(clsId, BusinessConsts.OrgRole.Student).stream().map(OrgUser::getUserId).collect(Collectors.toSet());
SysUser sysUser = importVO.convert2DB();
sysUser.setAccount(sysUser.getAccount() + topOrg.getCode());
UserVO userVO = iSysUserService.queryUserByAccount(sysUser.getAccount());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(userVO == null || !studentIdSet.contains(userVO.getId()),
"该学生已在班级中");
this.importOrgUser(topOrg, cls.getId(), studentIdSet, importVO);
}

View File

@ -32,7 +32,7 @@ public interface IRunPlanRoutingService {
RunPlanRoutingVO queryUserRoutingById(Long userId, Long mapId, Long routingId);
List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long planId, String routingCode);
List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId,Long routingId);
@Transactional
void createDefaultRoutings(List<RunPlanRoutingVO> defaultRoutings);

View File

@ -56,12 +56,12 @@ public class RunPlanGenerator {
List<RunPlanRoutingVO> outboundRoutings = runPlanRoutingService.getUserRoutingByType(userId, mapVO.getId(), RunPlanRoutingVO.UserRoutingType.OUTBOUND);
inboundRoutings = runPlanRoutingService.getUserRoutingByType(userId, mapVO.getId(), RunPlanRoutingVO.UserRoutingType.INBOUND);
outboundRouting1 = outboundRoutings.stream().filter(outRouting ->
Objects.equals(outRouting.getEndSectionCode(), running1Routing.getStartSectionCode()) && !Objects.equals(outRouting.getRight(), running1Routing.getRight()))
Objects.equals(outRouting.getEndSectionCode(), running1Routing.getStartSectionCode()) /*|| outRouting.getParkSectionCodeList().contains(running1Routing.getParkSectionCodeList().get(1))*/ /*&& !Objects.equals(outRouting.getRight(), running1Routing.getRight())*/)
.sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().indexOf(running1Routing.getParkSectionCodeList().get(0))))
.findFirst().orElse(null);
outboundRouting2 = outboundRoutings.stream().filter(outRouting ->
Objects.equals(outRouting.getEndSectionCode(), running2Routing.getStartSectionCode()) && !Objects.equals(outRouting.getRight(), running2Routing.getRight()))
Objects.equals(outRouting.getEndSectionCode(), running2Routing.getStartSectionCode()) /*|| outRouting.getParkSectionCodeList().contains(running2Routing.getParkSectionCodeList().get(1))*/ /*&& !Objects.equals(outRouting.getRight(), running2Routing.getRight())*/)
.sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().indexOf(running2Routing.getParkSectionCodeList().get(0))))
.findFirst().orElse(null);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Objects.isNull(outboundRouting1) && Objects.isNull(outboundRouting2), "没有找到对应的出库交路");
@ -132,27 +132,41 @@ public class RunPlanGenerator {
}
private LocalTime getDepartEndTime(RunPlanInputData inputData, LinkedList<RunPlanTripVO> serviceTripList) {
LocalTime departEndTime;
List<RunPlanTripTimeVO> outBoundTimeList = serviceTripList.getFirst().getTimeList();
boolean second=false;
if(outBoundTimeList.size()==1){
second =true;
outBoundTimeList = serviceTripList.get(1).getTimeList();
}
RunPlanTripTimeVO tripTime = null;
LocalTime overTime = null;
k:
a:
for (int f = 1; f < outBoundTimeList.size(); f++) {
tripTime = outBoundTimeList.get(f);
for (int i = 0; i < serviceTripList.size(); i += 2) {
for (RunPlanTripTimeVO runPlanTripTimeVO : serviceTripList.get(1).getTimeList()) {
if (outBoundTimeList.get(f).getStationCode().equals(runPlanTripTimeVO.getStationCode())) {
tripTime = outBoundTimeList.get(f);
break a;
}
}
}
LocalTime overTime = null;
if (Objects.nonNull(tripTime)) {
h:
for (int i = second ? 1 : 0; i < serviceTripList.size(); i += 2) {
List<RunPlanTripTimeVO> secondTimeList = serviceTripList.get(i).getTimeList();
for (RunPlanTripTimeVO runPlanTripTimeVO : secondTimeList) {
if (Objects.equals(runPlanTripTimeVO.getStationCode(), tripTime.getStationCode())) {
if (runPlanTripTimeVO.getArrivalTime().isAfter(tripTime.getArrivalTime())) {
overTime = runPlanTripTimeVO.getArrivalTime();
break k;
break h;
}
break;
}
}
}
}
departEndTime = Objects.nonNull(overTime) ? overTime.minusSeconds(ChronoUnit.SECONDS.between(inputData.getBeginTime(), tripTime.getArrivalTime())) : LocalTime.of(12, 0);
LocalTime departEndTime = Objects.nonNull(overTime) ? overTime.minusSeconds(ChronoUnit.SECONDS.between(inputData.getBeginTime(), tripTime.getArrivalTime())) : LocalTime.of(12, 0);
return departEndTime;
}
@ -177,14 +191,60 @@ public class RunPlanGenerator {
}
}
private DepartEndTime getDepartEndTime(RunPlanInputData inputData, LinkedList<RunPlanTripVO> serviceTripList1, LinkedList<RunPlanTripVO> serviceTripList2) {
private DepartEndTime getDepartEndTime(RunPlanInputData inputData,
LinkedList<RunPlanTripVO> serviceTripList1, LinkedList<RunPlanTripVO> serviceTripList2) {
RunPlanTripVO firsttrip1 = serviceTripList1.getFirst();
RunPlanTripVO secondtrip1 = serviceTripList1.get(1);
boolean out1 = firsttrip1.getRight().equals(secondtrip1.getRight());
RunPlanTripVO firsttrip2 = serviceTripList2.getFirst();
RunPlanTripVO secondtrip2 = serviceTripList2.get(1);
boolean out2 = firsttrip2.getRight().equals(secondtrip2.getRight());
boolean same = firsttrip1.getRight().equals(firsttrip2.getRight());
Long interval1 = null;
LocalTime time11 = null;
LocalTime time12 = null;
RunPlanTripTimeVO collisionTripTime1 = null;
List<RunPlanTripTimeVO> firstTimeListOf1 = serviceTripList1.getFirst().getTimeList();
List<RunPlanTripTimeVO> secondTimeListOf2 = serviceTripList2.get(1).getTimeList();
int index1=0,index2 = 1;
if(same){
if(out1){
index1=1;
index2=index1+1;
}else if(out2){
index1=0;
index2=index1+1;
}else{
index1 = 0;
index2=index1+2;
}
}else{
if(out1 && out2){
index1 = 1;
index2 = 2;
}else if(out1){
index1 = 1;
index2 = 1;
}else if(out2){
index1 = 0;
index2 = 2;
}
}
// List<RunPlanTripTimeVO> firstTimeListOf1 = serviceTripList1.getFirst().getTimeList();
List<RunPlanTripTimeVO> firstTimeListOf1 = serviceTripList1.get(index1).getTimeList();
List<RunPlanTripTimeVO> secondTimeListOf2 = serviceTripList2.get(index2).getTimeList();
if(index1 ==0 && firstTimeListOf1.size()==1){
firstTimeListOf1 = serviceTripList1.get(index1+1).getTimeList();
if(out2){
secondTimeListOf2 = serviceTripList2.get(index2==2?index2:index2+1).getTimeList();
}
}
k:
for (int i = 1; i < firstTimeListOf1.size(); i++) {
@ -203,8 +263,16 @@ public class RunPlanGenerator {
LocalTime time22 = null;
LocalTime time21 = null;
RunPlanTripTimeVO collisionTripTime2 = null;
List<RunPlanTripTimeVO> firstTimeListOf2 = serviceTripList2.getFirst().getTimeList();
List<RunPlanTripTimeVO> secondTimeListOf1 = serviceTripList1.get(1).getTimeList();
// List<RunPlanTripTimeVO> firstTimeListOf2 = serviceTripList2.getFirst().getTimeList();
// List<RunPlanTripTimeVO> secondTimeListOf1 = serviceTripList1.get(1).getTimeList();
List<RunPlanTripTimeVO> firstTimeListOf2 = serviceTripList2.get(index1).getTimeList();
List<RunPlanTripTimeVO> secondTimeListOf1 = serviceTripList1.get(index2).getTimeList();
if (index1 == 0 && firstTimeListOf2.size() == 1) {
firstTimeListOf2 = serviceTripList2.get(index1 + 1).getTimeList();
if (out2) {
secondTimeListOf1 = serviceTripList1.get(index2 == 2 ? index2 : index2 + 1).getTimeList();
}
}
k:
for (int i = 1; i < firstTimeListOf2.size(); i++) {
@ -357,23 +425,31 @@ public class RunPlanGenerator {
}
}
if(!inputData.hasOutAndInBound()){
serviceTripList.getFirst().setIsOutbound(true);
serviceTripList.getLast().setIsInbound(true);
}
if (inputData.hasOutAndInBound()) {
//找最快回库交路
RunPlanRoutingVO inboundRouting;
if (loop) {
inboundRouting = inboundRoutings.stream().filter(inRouting ->
Objects.equals(inRouting.getStartStationCode(), otherLoop.getStartStationCode())/*&& Objects.equals(inRouting.getRight(), otherLoop.getRight())*/)
Objects.equals(inRouting.getStartSectionCode(), otherLoop.getStartSectionCode())/*&& Objects.equals(inRouting.getRight(), otherLoop.getRight())*/)
.sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().size()))
.findFirst().orElse(null);
} else {
inboundRouting = inboundRoutings.stream().filter(inRouting ->
Objects.equals(inRouting.getStartStationCode(), outRefLoop.getStartStationCode())/*&& Objects.equals(inRouting.getRight(), outRefLoop.getRight())*/)
Objects.equals(inRouting.getStartSectionCode(), outRefLoop.getStartSectionCode())/*&& Objects.equals(inRouting.getRight(), outRefLoop.getRight())*/)
.sorted(Comparator.comparingInt(o -> o.getParkSectionCodeList().size()))
.findFirst().orElse(null);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Objects.isNull(inboundRouting), String.format("起始区段[%s]的入库交路不存在", loop ? mapVO.findSection(otherLoop.getStartSectionCode()).getName() : mapVO.findSection(outRefLoop.getStartSectionCode()).getName()));
//构建回库计划
inputData.setInboundRouting(inboundRouting);
// inputData.setInboundRouting(inboundRouting);
//判断回库是否从终点区段开始
//如果不是 从上一次的车站
buildServiceTrip(inputData, mapVO, inboundRouting, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
}
return serviceTripList;
@ -478,6 +554,7 @@ public class RunPlanGenerator {
tripVO.setIsInbound(true);
tripVO.setIsReentry(false);
}
Boolean startTBIsFront = startTBIsFront(routing, mapVO);
LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();
int size = routing.getParkSectionCodeList().size();
for (int i = 0; i < size; i++) {
@ -486,10 +563,13 @@ public class RunPlanGenerator {
runPlanTripTimeVO.setStationCode(routingSection.getStationCode());
runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode());
if (CollectionUtils.isEmpty(tripList) && i == 0) {//首发车次
if (Objects.nonNull(startTBIsFront) && !startTBIsFront) {
continue;
}
runPlanTripTimeVO.setArrivalTime(inputData.getBeginTime());
runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime());
} else if (i == 0) { //其它车次发车
if (!startTBIsFront(routing, mapVO)) {
if (!startTBIsFront) {
continue;
}
RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routingSection.getStationCode());
@ -507,7 +587,6 @@ public class RunPlanGenerator {
? runPlanTripTimeVO.getArrivalTime()
: runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
} else {
Boolean startTBIsFront = startTBIsFront(routing, mapVO);
if (i == 1 && Objects.nonNull(startTBIsFront) && !startTBIsFront) {
RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routing.getStartStationCode());
runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime() : tripList.getLast().getEndTime().plusSeconds(reentryTime.getTbBack() - reentryTime.getTbFrom()));

View File

@ -1,598 +0,0 @@
//package club.joylink.rtss.services.runplan;
//
//import club.joylink.rtss.constants.BusinessConsts;
//import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
//import club.joylink.rtss.vo.client.map.MapVO;
//import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
//import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO;
//import club.joylink.rtss.vo.client.runplan.RunPlanTripVO;
//import club.joylink.rtss.vo.client.runplan.user.*;
//import club.joylink.rtss.vo.runplan.RunPlanInput;
//import club.joylink.rtss.vo.runplan.RunPlanInputData;
//import lombok.AllArgsConstructor;
//import lombok.Getter;
//import lombok.NoArgsConstructor;
//import lombok.Setter;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import java.time.LocalTime;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * 通用运行图生成
// */
//@Component
//public class RunPlanGenerator1 {
//
// private static final int OFFSET_TIME_HOURS = 2; //时间偏移早两小时
//
// @Autowired
// private IRunPlanRoutingService runPlanRoutingService;
// @Autowired
// private IRunPlanRunlevelService runPlanRunlevelService;
// @Autowired
// private IRunPlanParktimeService runPlanParktimeService;
// @Autowired
// private IRunPlanUserConfigService runPlanUserConfigService;
//
//
// public List<RunPlanTripVO> generatorTrips(Long userId, RunPlanInput runPlanInput, MapVO mapVO) {
//
// //校验发车停运时间
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getOverTime().isAfter(runPlanInput.getBeginTime()));
// //校验车站
//
// LocalTime beginTimeOffset = runPlanInput.getBeginTime().minusHours(OFFSET_TIME_HOURS);
// //向前推两小时如果到前一天则时间不合理
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(runPlanInput.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点");
// runPlanInput.setBeginTime(beginTimeOffset);
// runPlanInput.setOverTime(runPlanInput.getOverTime().minusHours(OFFSET_TIME_HOURS));
//
// //检查环路
// RunPlanRoutingVO running1Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), runPlanInput.getRunningRouting1());
// RunPlanRoutingVO running2Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), runPlanInput.getRunningRouting2());
// boolean isLoop = running1Routing.getParkSectionCodeList().get(0).getStationCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getStationCode())
// && running2Routing.getParkSectionCodeList().get(0).getStationCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode());
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isLoop, "运行两交路无法构成环路数据");
// //查站间运行等级
// List<RunPlanRunlevelVO> levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId());
// Map<String, Integer> runLevelTime = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(runPlanInput.getRunLevel())));
// //查停站时间
// List<RunPlanParkingTimeVO> parkTimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId());
// Map<String, Integer> parkTime = parkTimes.stream().collect(Collectors.toMap(RunPlanParkingTimeVO::getSectionCode, RunPlanParkingTimeVO::getParkingTime));
// //查折返
// RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userId, mapVO.getId());
// Map<String, RunPlanUserConfigVO.ReentryTime> userReentryData = checkStationReentry(mapVO, running1Routing, config);
// //生成车次
// LinkedList<RunPlanTripVO> tripList = new LinkedList<>();
// //是否同时相向发车
// boolean opposite = Objects.isNull(runPlanInput.getRight());
// if (opposite) {
// //相向发车
// int initialServiceNum = 1;
// /*分别先发一辆车,计算控制左右发车服务号*/
// //上个服务号发车时刻
// //首班发车时间,首班车往返回来时间 来限定发车服务数量
// ServiceTempResult tempResultLeft = new ServiceTempResult(runPlanInput.getBeginTime(), null);
// serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime, parkTime, userReentryData);
//
// //上个服务号发车时刻
// //首班发车时间,首班车往返回来时间 来限定发车服务数量
// ServiceTempResult tempResultRight = new ServiceTempResult(runPlanInput.getBeginTime(), null);
// serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultRight, true, runLevelTime, parkTime, userReentryData);
//
// LocalTime firstRoundTripTimeLeft = tempResultLeft.getFirstRoundTripTime();
// LocalTime firstRoundTripTimeRight = tempResultRight.getFirstRoundTripTime();
// tempResultRight.setFirstRoundTripTime(firstRoundTripTimeLeft);
// tempResultLeft.setFirstRoundTripTime(firstRoundTripTimeRight);
//
// //暂时先定义发完左行再发右行..
// do {
// tempResultLeft.setPreServiceDepartTime(tempResultLeft.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
// serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultLeft, false, runLevelTime, parkTime, userReentryData);
// } while (tempResultLeft.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()*2).compareTo(tempResultLeft.getFirstRoundTripTime()) <= 0);
// //发完左行再发右行
// do {
// tempResultRight.setPreServiceDepartTime(tempResultRight.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
// serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, tempResultRight, true, runLevelTime, parkTime, userReentryData);
// } while (tempResultRight.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()*2).compareTo(tempResultRight.getFirstRoundTripTime()) <= 0);
//
// } else {
// //单向发车
// allServiceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, tripList, runLevelTime, parkTime, userReentryData);
//
// }
// return tripList;
//
// }
//
// /**
// * 服务号发车
// */
// private void serviceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, int initialServiceNum, LinkedList<RunPlanTripVO> tripList, ServiceTempResult serviceTempResult, boolean isRight, Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData) {
// String serviceNumber = String.format("%03d", initialServiceNum);
// //初始化车次号,右行偶数左行奇数
// int initTripNumber = isRight ? 0 : 1;
// LocalTime lastTripEndTime;//一个车次终点时间
// LinkedList<RunPlanTripVO> tempTripList = new LinkedList<>();
// String endStation = null;
// //根据运行时间判断结束末班车次
// do {
// RunPlanRoutingVO routing = Objects.equals(running1Routing.getRight(), isRight) ? running1Routing : running2Routing;
// RunPlanTripVO runPlanTripVO = new RunPlanTripVO(routing);
// runPlanTripVO.setServiceNumber(serviceNumber);
// setDirectionCode(mapVO, runPlanTripVO);
// runPlanTripVO.setIsReentry(true);
// //车次号
// String tripNumber = String.format("%03d", initTripNumber++);
// runPlanTripVO.setTripNumber(runPlanTripVO.getDirectionCode() + tripNumber);
// //首班右行方向
// LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();//车次时刻表
// int size = routing.getParkSectionCodeList().size();
// for (int i = 0; i < size; i++) {
// RunPlanRoutingSection routingSection = routing.getParkSectionCodeList().get(i);
// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
// runPlanTripTimeVO.setStationCode(routingSection.getStationCode());
// runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode());
// if (CollectionUtils.isEmpty(tempTripList) && i == 0) {//首发车次
// runPlanTripTimeVO.setArrivalTime(serviceTempResult.getPreServiceDepartTime());
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime());
// } else if (i == 0) { //其它车次发车
// if (!startTBIsFront(routing, mapVO)) {
// continue;
// }
// RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routingSection.getStationCode());
// runPlanTripTimeVO.setArrivalTime(
// tempTripList.getLast().getEndTime().plusSeconds(reentryTime.getTbFront() - parkTimeMap.get(runPlanTripTimeVO.getSectionCode()) * 2));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// } else if (i == size - 1) {
// Boolean endTBIsFront = endTBIsFront(routing, mapVO);
// if (Objects.nonNull(endTBIsFront) && !endTBIsFront) {
// continue;
// }
// runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList)?tripList.getLast().getEndTime().plusSeconds(45)
// : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
// runPlanTripTimeVO.setDepartureTime(Objects.isNull(endTBIsFront)
// ? runPlanTripTimeVO.getArrivalTime()
// : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// } else {
// Boolean startTBIsFront = startTBIsFront(routing, mapVO);
// if (i == 1 && Objects.nonNull(startTBIsFront) && !startTBIsFront) {
// RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get( routing.getStartStationCode());
// runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tempTripList)?serviceTempResult.getPreServiceDepartTime():tempTripList.getLast().getEndTime().plusSeconds(reentryTime.getTbBack() - reentryTime.getTbFrom()));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// }else{
// runPlanTripTimeVO.setArrivalTime(tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// }
// }
// tripTimeList.add(runPlanTripTimeVO);
// }
// runPlanTripVO.setTimeList(tripTimeList);
// setTripTerminalTime(runPlanTripVO, routing,tripTimeList,reentryData);
// lastTripEndTime = runPlanTripVO.getEndTime();
// if(CollectionUtils.isEmpty(tempTripList)){
// runPlanTripVO.setIsOutbound(true);
// }
// tempTripList.add(runPlanTripVO);
// if (tempTripList.size() > 50) { // 最快半小时跑一趟的一天车次数如果大于这个可能死循环此时停止发车
// break;
// }
// isRight = !isRight;
// endStation = routing.getEndStationCode();
// } while (lastTripEndTime.isBefore(runPlanInput.getOverTime()));
// //设置服务号末班车次入库
// RunPlanTripVO lastrunPlanTrip = tempTripList.getLast();
// lastrunPlanTrip.setIsInbound(true);
// lastrunPlanTrip.setIsReentry(false);
// LinkedList<RunPlanTripTimeVO> tripTimeList = (LinkedList) lastrunPlanTrip.getTimeList();
// setTripEndTime(lastrunPlanTrip, endStation, tripTimeList, reentryData);
// tripList.addAll(tempTripList);
// if (Objects.isNull(serviceTempResult.getFirstRoundTripTime())) {
// serviceTempResult.setFirstRoundTripTime(tempTripList.get(0).getEndTime());
// }
// serviceTempResult.setPreServiceDepartTime(tempTripList.getFirst().getStartTime());
// }
//
// /**
// * 单向发车
// */
// private void allServiceNumberDepart(MapVO mapVO, RunPlanInput runPlanInput, RunPlanRoutingVO running1Routing, RunPlanRoutingVO running2Routing, LinkedList<RunPlanTripVO> tripList, Map<String, Integer> runLevelTime, Map<String, Integer> parkTime, Map<String, RunPlanUserConfigVO.ReentryTime> userReentryData) {
//
//
// //设置初始服务号
// int initialServiceNum = 1;
// //上个服务号发车时刻
// //首班发车时间,首班车往返回来时间 来限定发车服务数量
// ServiceTempResult serviceTempResult = new ServiceTempResult(runPlanInput.getBeginTime(), null);
// do {
// if (initialServiceNum != 1) {
// if(initialServiceNum==2){
// serviceTempResult.setFirstRoundTripTime(tripList.get(1).getEndTime());
// }
// serviceTempResult.setPreServiceDepartTime(serviceTempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()));
// }
// serviceNumberDepart(mapVO, runPlanInput, running1Routing, running2Routing, initialServiceNum++, tripList, serviceTempResult, runPlanInput.getRight(), runLevelTime, parkTime, userReentryData);
//
// } while (serviceTempResult.getPreServiceDepartTime().plusSeconds(runPlanInput.getDepartureTimeInterval()).compareTo(serviceTempResult.getFirstRoundTripTime()) <= 0);
//
// }
//
// public List<RunPlanTripVO> generatorTrips(Long userId, RunPlanInputData inputData, MapVO mapVO) {
// //校验时间
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getOverTime().isAfter(inputData.getBeginTime()),"输入参数错误:发车时间应早于结束时间");
// LocalTime beginTimeOffset = inputData.getBeginTime().minusHours(OFFSET_TIME_HOURS);
// //向前推两小时如果到前一天则时间不合理
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(inputData.getBeginTime().isAfter(beginTimeOffset), "发车时间过早,建议晚于上午两点");
// inputData.setBeginTime(beginTimeOffset);
// inputData.setOverTime(inputData.getOverTime().minusHours(OFFSET_TIME_HOURS));
//
// //查交路
// RunPlanRoutingVO outboundRouting = null;
// if (inputData.hasOutbound()) {
// outboundRouting = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getOutboundRouting());
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(outboundRouting.isOutBoundRoute(), "出库交路选择错误");
// }
// RunPlanRoutingVO inboundRouting = null;
// if (inputData.hasInbound()) {
// inboundRouting = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getInboundRouting());
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(inboundRouting.isInBoundRoute(), "入库交路选择错误");
// }
// RunPlanRoutingVO running1Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getRunningRouting1());
// RunPlanRoutingVO running2Routing = runPlanRoutingService.queryUserRoutingByCode(userId, mapVO.getId(), inputData.getRunningRouting2());
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(running1Routing.isLoopRoute() && running2Routing.isLoopRoute(), "环线交路选择错误");
//
// //构建环路 出入库关系
//
// //验证 出库和入库 一端折返轨 一段转换轨验证环路 两端折返轨 环路是否闭环 或出入库跟环路是否衔接
// boolean isLoop = running1Routing.getParkSectionCodeList().get(0).getSectionCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getSectionCode())
// && running2Routing.getParkSectionCodeList().get(0).getSectionCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getSectionCode());
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isLoop, "运行两交路无法构成环路数据");
//
// boolean outToRun1 = outboundRouting.getParkSectionCodeList().get(outboundRouting.getParkSectionCodeList().size() - 1).getSectionCode().equals(running1Routing.getParkSectionCodeList().get(0).getSectionCode());
// boolean outToRun2 = outboundRouting.getParkSectionCodeList().get(outboundRouting.getParkSectionCodeList().size() - 1).getSectionCode().equals(running2Routing.getParkSectionCodeList().get(0).getSectionCode());
//
// boolean inToRun1 = inboundRouting.getParkSectionCodeList().get(0).getSectionCode().equals(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getSectionCode());
// boolean inToRun2 = inboundRouting.getParkSectionCodeList().get(0).getSectionCode().equals(running2Routing.getParkSectionCodeList().get(running2Routing.getParkSectionCodeList().size() - 1).getSectionCode());
//
// //出库的衔接环路
// RunPlanRoutingVO outRefLoop;
// //另一个交路
// RunPlanRoutingVO otherLoop;
// boolean same = false;
// if (outToRun1 && inToRun1) {
// same = true;
// outRefLoop = running1Routing;
// otherLoop = running2Routing;
// } else if (outToRun2 && inToRun2) {
// same = true;
// outRefLoop = running2Routing;
// otherLoop = running1Routing;
// } else if (outToRun1 && inToRun2) {
// outRefLoop = running1Routing;
// otherLoop = running2Routing;
// } else if (outToRun2 && inToRun1) {
// outRefLoop = running2Routing;
// otherLoop = running1Routing;
// } else {
// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出入库交路与运行环路无法衔接匹配");
// }
// //查站间运行等级
// List<RunPlanRunlevelVO> levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId());
// Map<String, Integer> runLevelMap = levels.stream().collect(Collectors.toMap(runLevelVO -> String.format("%s-%s", runLevelVO.getStartSectionCode(), runLevelVO.getEndSectionCode()), runLevelVO -> runLevelVO.getLevelTime(inputData.getRunLevel())));
// //查停站时间
// List<RunPlanParkingTimeVO> parktimes = runPlanParktimeService.queryUserParktimes(userId, mapVO.getId());
// Map<String, Integer> parkTimeMap = parktimes.stream().collect(Collectors.toMap(RunPlanParkingTimeVO::getSectionCode, RunPlanParkingTimeVO::getParkingTime));
// //查折返
// RunPlanUserConfigVO config = runPlanUserConfigService.getConfig(userId, mapVO.getId());
// Map<String, RunPlanUserConfigVO.ReentryTime> reentryData = checkStationReentry(mapVO, running1Routing, config);
// List<RunPlanTripVO> tripList = new ArrayList<>(100);
// ServiceTempResult serviceResult = new ServiceTempResult();
// //单个服务号还是多个
// if (Objects.nonNull(inputData.getDepartureInterval())) {
// do {
// generateService(inputData, mapVO, outboundRouting, inboundRouting, outRefLoop, same, otherLoop, runLevelMap, parkTimeMap, reentryData, tripList, serviceResult);
// inputData.setServiceNumber(String.format("%03d", Integer.parseInt(inputData.getServiceNumber()) + 1));
// inputData.setBeginTime(inputData.getBeginTime().plusSeconds(inputData.getDepartureInterval()));
// } while (serviceResult.preServiceDepartTime.plusSeconds(inputData.getDepartureInterval()).compareTo(serviceResult.firstRoundTripTime) <= 0);
//
// } else {
// generateService(inputData, mapVO, outboundRouting, inboundRouting, outRefLoop, same, otherLoop, runLevelMap, parkTimeMap, reentryData, tripList, serviceResult);
// }
// return tripList;
// }
//
// private Map<String, RunPlanUserConfigVO.ReentryTime> checkStationReentry(MapVO mapVO, RunPlanRoutingVO running1Routing, RunPlanUserConfigVO config) {
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(config) && config.hasReentryData(), "请配置所选运行线路折返数据");
// Map<String, RunPlanUserConfigVO.ReentryTime> reentryData = config.getConfig().getReentryData();
// // 检测折返站配置
// String startStationCode = running1Routing.getParkSectionCodeList().get(0).getStationCode();
// String endStationCode = running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode();
// if (Objects.isNull(reentryData.get(startStationCode))) {
// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("车站[%s]缺少折返数据", mapVO.findStation(startStationCode).getName()));
// }
// if(Objects.isNull(reentryData.get(endStationCode))){
// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("车站[%s]缺少折返数据", mapVO.findStation(endStationCode).getName()));
// }
// Boolean startTBIsFront = startTBIsFront(running1Routing, mapVO);
// if(Objects.nonNull(startTBIsFront) ){
// if (startTBIsFront) {
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(startStationCode).getTbFront()), String.format("车站[%s]请配置站前折返数据", mapVO.findStation(startStationCode).getName()));
// } else {
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(startStationCode).getTbBack()), String.format("车站[%s]请配置站后折返数据", mapVO.findStation(startStationCode).getName()));
// }
// }
//
// Boolean endTBIsFront = endTBIsFront(running1Routing, mapVO);
// if(Objects.nonNull(endTBIsFront) ){
// if (endTBIsFront) {
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(endStationCode).getTbFront()), String.format("车站[%s]请配置站前折返数据", mapVO.findStation(endStationCode).getName()));
// } else {
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(endStationCode).getTbBack()), String.format("车站[%s]请配置站后折返数据", mapVO.findStation(endStationCode).getName()));
// }
// }
// return reentryData;
// }
//
// private void generateService(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO outboundRouting, RunPlanRoutingVO inboundRouting, RunPlanRoutingVO outRefLoop, final boolean same, RunPlanRoutingVO otherLoop, Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, List<RunPlanTripVO> tripList, ServiceTempResult serviceResult) {
// LinkedList<RunPlanTripVO> serviceTripList = new LinkedList<>();
// int nextTripNumber = 1;
// //构建出库车次
// nextTripNumber = buildServiceTrip(inputData, mapVO, outboundRouting, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
//
// //计算入库车次运行所需时间
// int num = inboundRouting.getParkSectionCodeList().size() - 1;
// int inboundTripRunTime = 0;
// int parkTime=0;
// int runTime;
// for (int i = 0; i < num - 1; i++) {
// RunPlanRoutingSection routingSection = inboundRouting.getParkSectionCodeList().get(i);
// RunPlanRoutingSection nextRoutingSection = inboundRouting.getParkSectionCodeList().get(i + 1);
// if (i == 0) {
// if (startTBIsFront(inboundRouting, mapVO)) {
// parkTime = reentryData.get(routingSection.getStationCode()).getTbFront() - parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// } else {
// runTime = reentryData.get(routingSection.getStationCode()).getTbBack() - reentryData.get(routingSection.getStationCode()).getTbFrom();
// }
// } else {
// parkTime = parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }
// inboundTripRunTime = inboundTripRunTime + parkTime + runTime;
// parkTime = 0;
// }
//
// //计算出库对接环路运行所需时间
// int oNum = outRefLoop.getParkSectionCodeList().size() - 1;
// int outRefTripRunTime = 0;
// for (int i = 0; i < oNum; i++) {
// RunPlanRoutingSection routingSection = outRefLoop.getParkSectionCodeList().get(i);
// RunPlanRoutingSection nextRoutingSection = outRefLoop.getParkSectionCodeList().get(i + 1);
// if(i==0){
// if(startTBIsFront(outRefLoop, mapVO)){
// parkTime = reentryData.get(routingSection.getStationCode()).getTbFront()- parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }else {
// runTime = reentryData.get(routingSection.getStationCode()).getTbBack()-reentryData.get(routingSection.getStationCode()).getTbFrom();
// }
// }else if(i == oNum-1){
// if(endTBIsFront(outRefLoop,mapVO )){
// parkTime = parkTimeMap.get(routingSection.getSectionCode())+parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }else{
// parkTime = parkTimeMap.get(routingSection.getSectionCode());
// runTime = reentryData.get(nextRoutingSection.getStationCode()).getTbFrom();
// }
// }else{
// parkTime = parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }
// outRefTripRunTime = outRefTripRunTime + parkTime + runTime;
// parkTime = 0;
// }
//
// //计算另一环路运行所需时间
// int iNum = otherLoop.getParkSectionCodeList().size()-1;
// int otherTripRunTime = 0;
// for (int i = 0; i < iNum; i++) {
// RunPlanRoutingSection routingSection = otherLoop.getParkSectionCodeList().get(i);
// RunPlanRoutingSection nextRoutingSection = otherLoop.getParkSectionCodeList().get(i + 1);
// if(i==0){
// if(startTBIsFront(otherLoop, mapVO)){
// parkTime = reentryData.get(routingSection.getStationCode()).getTbFront()- parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }else {
// runTime = reentryData.get(routingSection.getStationCode()).getTbBack()-reentryData.get(routingSection.getStationCode()).getTbFrom();
// }
// }else if(i == iNum-1){
// if(endTBIsFront(otherLoop,mapVO )){
// parkTime = parkTimeMap.get(routingSection.getSectionCode())+parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }else{
// parkTime = parkTimeMap.get(routingSection.getSectionCode());
// runTime = reentryData.get(nextRoutingSection.getStationCode()).getTbFrom();
// }
// }else{
// parkTime = parkTimeMap.get(routingSection.getSectionCode());
// runTime = runLevelMap.get(routingSection.getSectionCode() + "-" + nextRoutingSection.getSectionCode());
// }
// otherTripRunTime = otherTripRunTime + parkTime + runTime;
// parkTime = 0;
// }
// if (same ? true :
// (serviceTripList.getLast().getEndTime().plusSeconds(inboundTripRunTime).isBefore(inputData.getOverTime()) &&
// (serviceTripList.getLast().getEndTime().getHour()<3
// || serviceTripList.getLast().getEndTime().plusSeconds(outRefTripRunTime + otherTripRunTime + inboundTripRunTime).getHour() > 3))
// ) {
// //构建环路车次
// boolean loop = false;
// do {
// if (same) {
// if (!loop) {
// nextTripNumber = buildServiceTrip(inputData, mapVO, outRefLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
// loop = true;
// } else {
// nextTripNumber = buildServiceTrip(inputData, mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
// nextTripNumber = buildServiceTrip(inputData, mapVO, outRefLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
// }
// } else {
// nextTripNumber = buildServiceTrip(inputData, mapVO, outRefLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
// nextTripNumber = buildServiceTrip(inputData, mapVO, otherLoop, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
// }
// }
// while (serviceTripList.getLast().getEndTime().plusSeconds(inboundTripRunTime).isBefore(inputData.getOverTime())
// &&
// (serviceTripList.getLast().getEndTime().getHour() < 3 || serviceTripList.getLast().getEndTime().plusSeconds(outRefTripRunTime + otherTripRunTime + inboundTripRunTime).getHour() > 3));
// }
// //构建回库计划
// buildServiceTrip(inputData, mapVO, inboundRouting, runLevelMap, parkTimeMap, reentryData, serviceTripList, nextTripNumber);
//
// if (Objects.isNull(serviceResult.getFirstRoundTripTime())) {
// serviceResult.setFirstRoundTripTime(serviceTripList.get(1).getEndTime());
// }
// serviceResult.setPreServiceDepartTime(serviceTripList.getFirst().getStartTime());
// tripList.addAll(serviceTripList);
// }
//
// private int buildServiceTrip(RunPlanInputData inputData, MapVO mapVO, RunPlanRoutingVO routing,
// Map<String, Integer> runLevelMap, Map<String, Integer> parkTimeMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData,
// LinkedList<RunPlanTripVO> tripList, int tripNumber) {
// RunPlanTripVO tripVO = new RunPlanTripVO(routing);
// setDirectionCode(mapVO, tripVO);
// tripVO.setServiceNumber(inputData.getServiceNumber());
// tripVO.setTripNumber(tripVO.getDirectionCode() + String.format("%03d", tripNumber));
// tripVO.setIsReentry(true);
// if (routing.isOutBoundRoute()) {
// tripVO.setIsOutbound(true);
// }
// if (routing.isInBoundRoute()) {
// tripVO.setIsInbound(true);
// tripVO.setIsReentry(false);
// }
// LinkedList<RunPlanTripTimeVO> tripTimeList = new LinkedList<>();
// int size = routing.getParkSectionCodeList().size();
// for (int i = 0; i < size; i++) {
// RunPlanRoutingSection routingSection = routing.getParkSectionCodeList().get(i);
// RunPlanTripTimeVO runPlanTripTimeVO = new RunPlanTripTimeVO();
// runPlanTripTimeVO.setStationCode(routingSection.getStationCode());
// runPlanTripTimeVO.setSectionCode(routingSection.getSectionCode());
// if (CollectionUtils.isEmpty(tripList) && i == 0) {//首发车次
// runPlanTripTimeVO.setArrivalTime(inputData.getBeginTime());
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime());
// } else if (i == 0) { //其它车次发车
// if (!startTBIsFront(routing, mapVO)) {
// continue;
// }
// RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routingSection.getStationCode());
// runPlanTripTimeVO.setArrivalTime(
// tripList.getLast().getEndTime().plusSeconds(reentryTime.getTbFront() - parkTimeMap.get(runPlanTripTimeVO.getSectionCode()) * 2));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// } else if (i == size - 1) {
// Boolean endTBIsFront = endTBIsFront(routing, mapVO);
// if (Objects.nonNull(endTBIsFront) && !endTBIsFront) {
// continue;
// }
// runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripTimeList)?tripList.getLast().getEndTime().plusSeconds(45)
// : tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
// runPlanTripTimeVO.setDepartureTime(Objects.isNull(endTBIsFront)
// ? runPlanTripTimeVO.getArrivalTime()
// : runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// } else {
// Boolean startTBIsFront = startTBIsFront(routing, mapVO);
// if (i == 1 && Objects.nonNull(startTBIsFront) && !startTBIsFront) {
// RunPlanUserConfigVO.ReentryTime reentryTime = reentryData.get(routing.getStartStationCode());
// runPlanTripTimeVO.setArrivalTime(CollectionUtils.isEmpty(tripList) ? inputData.getBeginTime() : tripList.getLast().getEndTime().plusSeconds(reentryTime.getTbBack() - reentryTime.getTbFrom()));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// } else {
// runPlanTripTimeVO.setArrivalTime(tripTimeList.getLast().getDepartureTime().plusSeconds(runLevelMap.get(tripTimeList.getLast().getSectionCode() + "-" + runPlanTripTimeVO.getSectionCode())));
// runPlanTripTimeVO.setDepartureTime(runPlanTripTimeVO.getArrivalTime().plusSeconds(parkTimeMap.get(runPlanTripTimeVO.getSectionCode())));
// }
// }
// tripTimeList.add(runPlanTripTimeVO);
// }
// tripVO.setTimeList(tripTimeList);
// setTripTerminalTime(tripVO, routing,tripTimeList, reentryData);
// tripList.add(tripVO);
// return ++tripNumber;
// }
//
// private void setDirectionCode(MapVO mapVO, RunPlanTripVO tripVO) {
// if (mapVO.getConfigVO().getUpRight()) {
// if (tripVO.getRight()) {
// tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02);
// } else {
// tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01);
// }
// } else {
// if (tripVO.getRight()) {
// tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type01);
// } else {
// tripVO.setDirectionCode(BusinessConsts.RunPlan.DirectionType.Type02);
// }
// }
// }
//
// public void setTripTerminalTime(RunPlanTripVO runPlanTripVO, RunPlanRoutingVO routing,LinkedList<RunPlanTripTimeVO> tripTimeList, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData) {
// setTripStartTime(runPlanTripVO, routing.getStartStationCode(),tripTimeList, reentryData);
// setTripEndTime(runPlanTripVO, routing.getEndStationCode(),tripTimeList, reentryData);
// }
//
// private void setTripStartTime(RunPlanTripVO runPlanTripVO, String startStation,LinkedList<RunPlanTripTimeVO> tripTimeList, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData) {
// RunPlanTripTimeVO firstTripTime = tripTimeList.getFirst();
// if (Objects.equals(runPlanTripVO.getStartSectionCode(), firstTripTime.getSectionCode())) {
// runPlanTripVO.setStartTime(tripTimeList.getFirst().getArrivalTime());
// } else {
//// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(firstTripTime.getStationCode()).getTbTo()), String.format("车站[%s]折返数据请配置折返轨至起始股道",firstTripTime.getStationCode()));
// runPlanTripVO.setStartTime(firstTripTime.getArrivalTime().minusSeconds(reentryData.get(startStation).getTbTo()));
// }
// }
//
// private void setTripEndTime(RunPlanTripVO runPlanTripVO, String endStation,LinkedList<RunPlanTripTimeVO> tripTimeList, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData) {
// RunPlanTripTimeVO lastTripTime = tripTimeList.getLast();
// if (Objects.equals(runPlanTripVO.getEndSectionCode(), lastTripTime.getSectionCode())) {
// runPlanTripVO.setEndTime(lastTripTime.getDepartureTime());
// } else if(Objects.equals(runPlanTripVO.getStartSectionCode(), lastTripTime.getSectionCode())){
// runPlanTripVO.setEndTime(lastTripTime.getDepartureTime().plusSeconds(45));//转换轨直接到折返轨的交路
// } else{
//// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(reentryData.get(lastTripTime.getStationCode()).getTbFrom()), String.format("车站[%s]折返数据请配置轨道至折返轨",lastTripTime.getStationCode()));
//
// runPlanTripVO.setEndTime(lastTripTime.getDepartureTime().plusSeconds(reentryData.get(endStation).getTbFrom()));
// }
// }
//
// public Boolean startTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) {
// MapSectionNewVO startReentrySection = mapVO.findSection(runningRouting.getStartSectionCode());
// if (startReentrySection.isReentryTrack()) {
// if (startReentrySection.isStandTrack()) {
// return true;
// }
// return false;
// }
// return null;
// }
//
// public Boolean endTBIsFront(RunPlanRoutingVO runningRouting, MapVO mapVO) {
// MapSectionNewVO endReentrySection = mapVO.findSection(runningRouting.getEndSectionCode());
// if (endReentrySection.isReentryTrack()) {
// if (endReentrySection.isStandTrack()) {
// return true;
// }
// return false;
// }
// return null;
// }
//
// @Getter
// @Setter
// @AllArgsConstructor
// @NoArgsConstructor
// private class ServiceTempResult {
// private LocalTime preServiceDepartTime;
// private LocalTime firstRoundTripTime;
// }
//
//}

View File

@ -365,7 +365,7 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
example.or().andMapIdEqualTo(mapId).andUserIdIsNull();
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExample(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId));
}
@ -400,14 +400,10 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
}
@Override
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long planId, String routingCode) {
RunPlanDraft runPlanDraft = runPlanDraftDAO.selectByPrimaryKey(planId);
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(runPlanDraft.getMapId()).andUserIdEqualTo(userId).andCodeEqualTo(routingCode);
example.or().andMapIdEqualTo(runPlanDraft.getMapId()).andUserIdIsNull().andCodeEqualTo(routingCode);
List<RunPlanRouting> list = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
return RunPlanRoutingVO.convert2VO(list.get(0)).getParkSectionCodeList();
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long routingId) {
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
if (Objects.isNull(routing)) return Collections.emptyList();
return RunPlanRoutingVO.convert2VO(routing).getParkSectionCodeList();
}

View File

@ -35,6 +35,4 @@ public class ExamDefinitionQueryVO extends PageQueryVO {
private String status;
private Integer clsId;
private boolean self;
}

View File

@ -32,4 +32,9 @@ public class LessonPublishVO {
@ApiModelProperty(value = "班级id集合")
private List<Long> classIdList;
/**
* 覆盖同名课程
*/
private boolean coverSameNameLesson;
}

View File

@ -16,9 +16,6 @@ public class LessonQueryVO extends PageQueryVO {
@ApiModelProperty(value = "地图id")
private Long mapId;
/**
* 是否仅查询自己的
*/
private boolean self;
private String creatorName;
}

View File

@ -14,5 +14,5 @@ public class OrgQueryVO extends PageQueryVO {
private Long topOrgId;
private boolean self;
private String creatorName;
}

View File

@ -73,4 +73,5 @@ public class RunPlanTripTimeVO {
this.arrivalTime = plan.getArriveTime();
this.departureTime = plan.getLeaveTime();
}
}

View File

@ -117,7 +117,7 @@ public class RunPlanTripVO {
public RunPlanTripVO(RunPlanRoutingVO routingVO) {
this.right = routingVO.getRight();
this.destinationCode = routingVO.getDestinationCode();
this.destinationCode = Objects.isNull(routingVO.getDestinationCode()) ? "" : routingVO.getDestinationCode();
this.startSectionCode = routingVO.getStartSectionCode();
this.endSectionCode = routingVO.getEndSectionCode();
this.timeList = new ArrayList<>();

View File

@ -10,6 +10,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@ -116,7 +118,9 @@ public class RunPlanRoutingVO {
routingVO.setRight(runPlanRouting.getRight());
routingVO.setDestinationCode(runPlanRouting.getDestinationCode());
routingVO.setRemarks(runPlanRouting.getRemarks());
routingVO.setParkSectionCodeList(JsonUtils.readCollection(runPlanRouting.getSectionData(), List.class, RunPlanRoutingSection.class));
if(StringUtils.hasText(runPlanRouting.getSectionData())){
routingVO.setParkSectionCodeList(JsonUtils.readCollection(runPlanRouting.getSectionData(), List.class, RunPlanRoutingSection.class));
}
routingVO.setReentryType(mapVO);
return routingVO;
}

View File

@ -50,9 +50,9 @@ public class RunPlanInputData {
private boolean outAndIn = false;
/**回库交路*/
@JsonIgnore
private RunPlanRoutingVO inboundRouting;
// /**回库交路*/
// @JsonIgnore
// private RunPlanRoutingVO inboundRouting;
@JsonIgnore
public boolean multiService() {