[新增]成工院虚仿平台对接的登录接口、统计数据并同步服务
This commit is contained in:
parent
5d15ba3240
commit
bef6dda6b2
|
@ -0,0 +1,41 @@
|
||||||
|
package club.joylink.rtss.aop;
|
||||||
|
|
||||||
|
import club.joylink.rtss.services.cgy.CgyStatsService;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.SimulationService;
|
||||||
|
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CgyViewAspect {
|
||||||
|
|
||||||
|
private CgyStatsService cgyStatsService;
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
private SimulationService simulationService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CgyViewAspect(CgyStatsService cgyStatsService, RestTemplate restTemplate,
|
||||||
|
SimulationService simulationService) {
|
||||||
|
this.cgyStatsService = cgyStatsService;
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
this.simulationService = simulationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成工院第三方登录接口被调用后,加一个浏览量,并同步给虚仿平台
|
||||||
|
*/
|
||||||
|
@AfterReturning(value = "execution(public * club.joylink.rtss.controller.LoginController.cgyThirdPartyLogin(..))")
|
||||||
|
public void addViewCount(JoinPoint joinPoint) {
|
||||||
|
Object arg = joinPoint.getArgs()[0];
|
||||||
|
CgyThirdPartyLoginInfoVO loginInfoVO = (CgyThirdPartyLoginInfoVO) arg;
|
||||||
|
cgyStatsService.updateView(loginInfoVO.getAppId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package club.joylink.rtss.bo.cgy;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成工院虚仿平台对接统计数据
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CgyStatsBO {
|
||||||
|
|
||||||
|
private final String appId;
|
||||||
|
private final String appSecret;
|
||||||
|
private final Long FunctionId;
|
||||||
|
//统计数据是否发生变化
|
||||||
|
private AtomicBoolean change;
|
||||||
|
//浏览量
|
||||||
|
private AtomicLong view;
|
||||||
|
//实训人次
|
||||||
|
private AtomicLong visitor;
|
||||||
|
//实训人数
|
||||||
|
private final Set<Long> userSet = new HashSet<>();
|
||||||
|
//实训时长
|
||||||
|
private AtomicLong duration;
|
||||||
|
}
|
|
@ -6,5 +6,6 @@ public interface ProjectCode {
|
||||||
String SR_SANDBOX = "SR_SANDBOX";
|
String SR_SANDBOX = "SR_SANDBOX";
|
||||||
String NGY_SAND_TABLE = "NGY_SAND_TABLE";
|
String NGY_SAND_TABLE = "NGY_SAND_TABLE";
|
||||||
String CDGXY = "CDGXY";
|
String CDGXY = "CDGXY";
|
||||||
|
String CGY = "CGY";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,136 +7,148 @@ import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.LoginStatusVO;
|
import club.joylink.rtss.vo.client.LoginStatusVO;
|
||||||
import club.joylink.rtss.vo.client.LoginUserVO;
|
import club.joylink.rtss.vo.client.LoginUserVO;
|
||||||
|
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
|
||||||
import club.joylink.rtss.vo.client.validGroup.LoginInfoCheck;
|
import club.joylink.rtss.vo.client.validGroup.LoginInfoCheck;
|
||||||
import club.joylink.rtss.vo.client.validGroup.ThirdLoginInfoCheck;
|
import club.joylink.rtss.vo.client.validGroup.ThirdLoginInfoCheck;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import javax.validation.constraints.NotBlank;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/login")
|
@RequestMapping("/api/login")
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAuthenticateService iAuthenticateService;
|
private IAuthenticateService iAuthenticateService;
|
||||||
|
|
||||||
@PostMapping(path = "/third")
|
@PostMapping("/cgy/third")
|
||||||
public String thirdPartyLogin(@RequestBody @Validated(ThirdLoginInfoCheck.class) LoginUserVO loginInfo) {
|
public String cgyThirdPartyLogin(@RequestBody @Validated CgyThirdPartyLoginInfoVO loginInfo) {
|
||||||
return this.iAuthenticateService.thirdPartyLogin(loginInfo);
|
return this.iAuthenticateService.cgyThirdPartyLogin(loginInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PostMapping(path = "/third")
|
||||||
* 获取微信小程序登陆二维码
|
public String thirdPartyLogin(
|
||||||
*/
|
@RequestBody @Validated(ThirdLoginInfoCheck.class) LoginUserVO loginInfo) {
|
||||||
@GetMapping(path = "/wmurl")
|
return this.iAuthenticateService.thirdPartyLogin(loginInfo);
|
||||||
public LoginStatusVO getWmLoginUrl(@NotBlank String clientId, @NotBlank String secret,
|
}
|
||||||
String project, @RequestParam(required = false) String deviceCode) {
|
|
||||||
try {
|
|
||||||
return this.iAuthenticateService.getWmLoginUrl(clientId, secret, project, deviceCode);
|
|
||||||
} catch (BaseException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("获取登录二维码失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户微信小程序扫登陆二维码
|
* 获取微信小程序登陆二维码
|
||||||
*/
|
*/
|
||||||
@GetMapping(path = "/scan/wmLoginUrl")
|
@GetMapping(path = "/wmurl")
|
||||||
public AccountVO scanWmLoginQrCode(String code, String state) {
|
public LoginStatusVO getWmLoginUrl(@NotBlank String clientId, @NotBlank String secret,
|
||||||
return this.iAuthenticateService.scanWmLoginQrCode(code, state);
|
String project, @RequestParam(required = false) String deviceCode) {
|
||||||
|
try {
|
||||||
|
return this.iAuthenticateService.getWmLoginUrl(clientId, secret, project, deviceCode);
|
||||||
|
} catch (BaseException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("获取登录二维码失败");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序确认登陆接口
|
* 用户微信小程序扫登陆二维码
|
||||||
*/
|
*/
|
||||||
@PostMapping(path = "/wm")
|
@GetMapping(path = "/scan/wmLoginUrl")
|
||||||
public void wmConfirmLogin(String code, String state) {
|
public AccountVO scanWmLoginQrCode(String code, String state) {
|
||||||
this.iAuthenticateService.wmConfirmClientLogin(code, state);
|
return this.iAuthenticateService.scanWmLoginQrCode(code, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping()
|
/**
|
||||||
public String loginWithPwd(@RequestBody @Validated(LoginInfoCheck.class) LoginUserVO loginUser) {
|
* 微信小程序确认登陆接口
|
||||||
return iAuthenticateService.loginWithPwd(loginUser);
|
*/
|
||||||
}
|
@PostMapping(path = "/wm")
|
||||||
|
public void wmConfirmLogin(String code, String state) {
|
||||||
|
this.iAuthenticateService.wmConfirmClientLogin(code, state);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/preLogout")
|
@PostMapping()
|
||||||
public void preLogout(String token) {
|
public String loginWithPwd(@RequestBody @Validated(LoginInfoCheck.class) LoginUserVO loginUser) {
|
||||||
this.iAuthenticateService.preLogout(token);
|
return iAuthenticateService.loginWithPwd(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/logout")
|
@GetMapping("/preLogout")
|
||||||
public void logout(String token) {
|
public void preLogout(String token) {
|
||||||
this.iAuthenticateService.logout(token);
|
this.iAuthenticateService.preLogout(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/checkStatus")
|
@GetMapping(path = "/logout")
|
||||||
public LoginStatusVO checkStatus(@NotBlank String sessionId) {
|
public void logout(String token) {
|
||||||
return iAuthenticateService.checkStatus(sessionId);
|
this.iAuthenticateService.logout(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@GetMapping(path = "/checkStatus")
|
||||||
* 获取用户信息 - 通过token
|
public LoginStatusVO checkStatus(@NotBlank String sessionId) {
|
||||||
*
|
return iAuthenticateService.checkStatus(sessionId);
|
||||||
* @param token
|
}
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping(path = "/getUserInfo")
|
|
||||||
public AccountVO getUserInfo(String token) {
|
|
||||||
LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token);
|
|
||||||
return loginUserInfoVO.getAccountVO();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户登录信息(包含登录的项目/客户端等)
|
* 获取用户信息 - 通过token
|
||||||
*
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/loginUserInfo")
|
@GetMapping(path = "/getUserInfo")
|
||||||
public LoginUserInfoVO getLoginUserInfo(String token) {
|
public AccountVO getUserInfo(String token) {
|
||||||
return this.iAuthenticateService.getLoginUserInfoByToken(token);
|
LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token);
|
||||||
}
|
return loginUserInfoVO.getAccountVO();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <玖琏科技>微信小程序code换取token
|
* 获取用户登录信息(包含登录的项目/客户端等)
|
||||||
*/
|
*
|
||||||
@GetMapping(path = "/wm/token")
|
* @param token
|
||||||
public String getTokenByWmCode(String code) {
|
* @return
|
||||||
return this.iAuthenticateService.getTokenByWmCode(code);
|
*/
|
||||||
}
|
@GetMapping("/loginUserInfo")
|
||||||
|
public LoginUserInfoVO getLoginUserInfo(String token) {
|
||||||
|
return this.iAuthenticateService.getLoginUserInfoByToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 到那儿了小程序code换token
|
* <玖琏科技>微信小程序code换取token
|
||||||
*
|
*/
|
||||||
* @param code
|
@GetMapping(path = "/wm/token")
|
||||||
* @return
|
public String getTokenByWmCode(String code) {
|
||||||
*/
|
return this.iAuthenticateService.getTokenByWmCode(code);
|
||||||
@GetMapping(path = "/wm2/token")
|
}
|
||||||
public String getTokenByWmCode2(String code) {
|
|
||||||
return this.iAuthenticateService.getTokenByWmCode2(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 郑州共赢小程序code换token
|
* 到那儿了小程序code换token
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping(path = "/wm/zzww/token")
|
@GetMapping(path = "/wm2/token")
|
||||||
public String getTokenByWmCode3(String code) {
|
public String getTokenByWmCode2(String code) {
|
||||||
return this.iAuthenticateService.getTokenByWmCode3(code);
|
return this.iAuthenticateService.getTokenByWmCode2(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token是否过期
|
* 郑州共赢小程序code换token
|
||||||
*/
|
*
|
||||||
@GetMapping(path = "/{token}/isExpired")
|
* @param code
|
||||||
public boolean isTokenExpired(@PathVariable String token) {
|
* @return
|
||||||
return this.iAuthenticateService.isTokenExpired(token);
|
*/
|
||||||
}
|
@GetMapping(path = "/wm/zzww/token")
|
||||||
|
public String getTokenByWmCode3(String code) {
|
||||||
|
return this.iAuthenticateService.getTokenByWmCode3(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token是否过期
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{token}/isExpired")
|
||||||
|
public boolean isTokenExpired(@PathVariable String token) {
|
||||||
|
return this.iAuthenticateService.isTokenExpired(token);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,10 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -591,16 +589,7 @@ public class SimulationV1Controller {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
|
public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
|
||||||
List<Simulation> simulationList = this.simulationManager.getSimulationList();
|
return simulationService.listAllSimulation(queryVO);
|
||||||
Stream<Simulation> stream = simulationList.stream();
|
|
||||||
if (StringUtils.hasText(queryVO.getGroup())) {
|
|
||||||
stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
|
||||||
}
|
|
||||||
if (StringUtils.hasText(queryVO.getUserName())) {
|
|
||||||
stream = stream.filter(simulation -> simulation.getSimulationUsers().stream()
|
|
||||||
.anyMatch(user -> user.getName().contains(queryVO.getUserName())));
|
|
||||||
}
|
|
||||||
return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package club.joylink.rtss.dao;
|
||||||
|
|
||||||
|
import club.joylink.rtss.entity.CgyView;
|
||||||
|
import club.joylink.rtss.entity.CgyViewExample;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CgyViewDAO继承基类
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface CgyViewDAO extends MyBatisBaseDao<CgyView, String, CgyViewExample> {
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
//package club.joylink.rtss.dao;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.entity.Company;
|
|
||||||
//import club.joylink.rtss.entity.CompanyExample;
|
|
||||||
//import org.springframework.stereotype.Repository;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * CompanyDAO继承基类
|
|
||||||
// */
|
|
||||||
////@Repository
|
|
||||||
////public interface CompanyDAO extends MyBatisBaseDao<Company, Integer, CompanyExample> {
|
|
||||||
////}
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package club.joylink.rtss.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cgy_view
|
||||||
|
* @author
|
||||||
|
*/
|
||||||
|
public class CgyView implements Serializable {
|
||||||
|
/**
|
||||||
|
* 接入虚仿平台后获取
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入虚仿平台后获取
|
||||||
|
*/
|
||||||
|
private String appSecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地图功能id
|
||||||
|
*/
|
||||||
|
private Long functionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览量
|
||||||
|
*/
|
||||||
|
private Long viewCount;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public String getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppId(String appId) {
|
||||||
|
this.appId = appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppSecret() {
|
||||||
|
return appSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppSecret(String appSecret) {
|
||||||
|
this.appSecret = appSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFunctionId() {
|
||||||
|
return functionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFunctionId(Long functionId) {
|
||||||
|
this.functionId = functionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getViewCount() {
|
||||||
|
return viewCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewCount(Long viewCount) {
|
||||||
|
this.viewCount = viewCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CgyView other = (CgyView) that;
|
||||||
|
return (this.getAppId() == null ? other.getAppId() == null : this.getAppId().equals(other.getAppId()))
|
||||||
|
&& (this.getAppSecret() == null ? other.getAppSecret() == null : this.getAppSecret().equals(other.getAppSecret()))
|
||||||
|
&& (this.getFunctionId() == null ? other.getFunctionId() == null : this.getFunctionId().equals(other.getFunctionId()))
|
||||||
|
&& (this.getViewCount() == null ? other.getViewCount() == null : this.getViewCount().equals(other.getViewCount()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getAppId() == null) ? 0 : getAppId().hashCode());
|
||||||
|
result = prime * result + ((getAppSecret() == null) ? 0 : getAppSecret().hashCode());
|
||||||
|
result = prime * result + ((getFunctionId() == null) ? 0 : getFunctionId().hashCode());
|
||||||
|
result = prime * result + ((getViewCount() == null) ? 0 : getViewCount().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", appId=").append(appId);
|
||||||
|
sb.append(", appSecret=").append(appSecret);
|
||||||
|
sb.append(", functionId=").append(functionId);
|
||||||
|
sb.append(", viewCount=").append(viewCount);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,482 @@
|
||||||
|
package club.joylink.rtss.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CgyViewExample {
|
||||||
|
protected String orderByClause;
|
||||||
|
|
||||||
|
protected boolean distinct;
|
||||||
|
|
||||||
|
protected List<Criteria> oredCriteria;
|
||||||
|
|
||||||
|
private Integer limit;
|
||||||
|
|
||||||
|
private Long offset;
|
||||||
|
|
||||||
|
public CgyViewExample() {
|
||||||
|
oredCriteria = new ArrayList<Criteria>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderByClause(String orderByClause) {
|
||||||
|
this.orderByClause = orderByClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrderByClause() {
|
||||||
|
return orderByClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistinct(boolean distinct) {
|
||||||
|
this.distinct = distinct;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDistinct() {
|
||||||
|
return distinct;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Criteria> getOredCriteria() {
|
||||||
|
return oredCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void or(Criteria criteria) {
|
||||||
|
oredCriteria.add(criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria or() {
|
||||||
|
Criteria criteria = createCriteriaInternal();
|
||||||
|
oredCriteria.add(criteria);
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria createCriteria() {
|
||||||
|
Criteria criteria = createCriteriaInternal();
|
||||||
|
if (oredCriteria.size() == 0) {
|
||||||
|
oredCriteria.add(criteria);
|
||||||
|
}
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criteria createCriteriaInternal() {
|
||||||
|
Criteria criteria = new Criteria();
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
oredCriteria.clear();
|
||||||
|
orderByClause = null;
|
||||||
|
distinct = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(Integer limit) {
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLimit() {
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(Long offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract static class GeneratedCriteria {
|
||||||
|
protected List<Criterion> criteria;
|
||||||
|
|
||||||
|
protected GeneratedCriteria() {
|
||||||
|
super();
|
||||||
|
criteria = new ArrayList<Criterion>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return criteria.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Criterion> getAllCriteria() {
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Criterion> getCriteria() {
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addCriterion(String condition) {
|
||||||
|
if (condition == null) {
|
||||||
|
throw new RuntimeException("Value for condition cannot be null");
|
||||||
|
}
|
||||||
|
criteria.add(new Criterion(condition));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addCriterion(String condition, Object value, String property) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||||
|
}
|
||||||
|
criteria.add(new Criterion(condition, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||||
|
if (value1 == null || value2 == null) {
|
||||||
|
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||||
|
}
|
||||||
|
criteria.add(new Criterion(condition, value1, value2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdIsNull() {
|
||||||
|
addCriterion("app_id is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdIsNotNull() {
|
||||||
|
addCriterion("app_id is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdEqualTo(String value) {
|
||||||
|
addCriterion("app_id =", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdNotEqualTo(String value) {
|
||||||
|
addCriterion("app_id <>", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdGreaterThan(String value) {
|
||||||
|
addCriterion("app_id >", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdGreaterThanOrEqualTo(String value) {
|
||||||
|
addCriterion("app_id >=", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdLessThan(String value) {
|
||||||
|
addCriterion("app_id <", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdLessThanOrEqualTo(String value) {
|
||||||
|
addCriterion("app_id <=", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdLike(String value) {
|
||||||
|
addCriterion("app_id like", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdNotLike(String value) {
|
||||||
|
addCriterion("app_id not like", value, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdIn(List<String> values) {
|
||||||
|
addCriterion("app_id in", values, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdNotIn(List<String> values) {
|
||||||
|
addCriterion("app_id not in", values, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdBetween(String value1, String value2) {
|
||||||
|
addCriterion("app_id between", value1, value2, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppIdNotBetween(String value1, String value2) {
|
||||||
|
addCriterion("app_id not between", value1, value2, "appId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretIsNull() {
|
||||||
|
addCriterion("app_secret is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretIsNotNull() {
|
||||||
|
addCriterion("app_secret is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretEqualTo(String value) {
|
||||||
|
addCriterion("app_secret =", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretNotEqualTo(String value) {
|
||||||
|
addCriterion("app_secret <>", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretGreaterThan(String value) {
|
||||||
|
addCriterion("app_secret >", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretGreaterThanOrEqualTo(String value) {
|
||||||
|
addCriterion("app_secret >=", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretLessThan(String value) {
|
||||||
|
addCriterion("app_secret <", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretLessThanOrEqualTo(String value) {
|
||||||
|
addCriterion("app_secret <=", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretLike(String value) {
|
||||||
|
addCriterion("app_secret like", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretNotLike(String value) {
|
||||||
|
addCriterion("app_secret not like", value, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretIn(List<String> values) {
|
||||||
|
addCriterion("app_secret in", values, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretNotIn(List<String> values) {
|
||||||
|
addCriterion("app_secret not in", values, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretBetween(String value1, String value2) {
|
||||||
|
addCriterion("app_secret between", value1, value2, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andAppSecretNotBetween(String value1, String value2) {
|
||||||
|
addCriterion("app_secret not between", value1, value2, "appSecret");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdIsNull() {
|
||||||
|
addCriterion("function_id is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdIsNotNull() {
|
||||||
|
addCriterion("function_id is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdEqualTo(Long value) {
|
||||||
|
addCriterion("function_id =", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdNotEqualTo(Long value) {
|
||||||
|
addCriterion("function_id <>", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdGreaterThan(Long value) {
|
||||||
|
addCriterion("function_id >", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdGreaterThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("function_id >=", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdLessThan(Long value) {
|
||||||
|
addCriterion("function_id <", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdLessThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("function_id <=", value, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdIn(List<Long> values) {
|
||||||
|
addCriterion("function_id in", values, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdNotIn(List<Long> values) {
|
||||||
|
addCriterion("function_id not in", values, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("function_id between", value1, value2, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andFunctionIdNotBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("function_id not between", value1, value2, "functionId");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountIsNull() {
|
||||||
|
addCriterion("view_count is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountIsNotNull() {
|
||||||
|
addCriterion("view_count is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountEqualTo(Long value) {
|
||||||
|
addCriterion("view_count =", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountNotEqualTo(Long value) {
|
||||||
|
addCriterion("view_count <>", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountGreaterThan(Long value) {
|
||||||
|
addCriterion("view_count >", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountGreaterThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("view_count >=", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountLessThan(Long value) {
|
||||||
|
addCriterion("view_count <", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountLessThanOrEqualTo(Long value) {
|
||||||
|
addCriterion("view_count <=", value, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountIn(List<Long> values) {
|
||||||
|
addCriterion("view_count in", values, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountNotIn(List<Long> values) {
|
||||||
|
addCriterion("view_count not in", values, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("view_count between", value1, value2, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andViewCountNotBetween(Long value1, Long value2) {
|
||||||
|
addCriterion("view_count not between", value1, value2, "viewCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public static class Criteria extends GeneratedCriteria {
|
||||||
|
|
||||||
|
protected Criteria() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Criterion {
|
||||||
|
private String condition;
|
||||||
|
|
||||||
|
private Object value;
|
||||||
|
|
||||||
|
private Object secondValue;
|
||||||
|
|
||||||
|
private boolean noValue;
|
||||||
|
|
||||||
|
private boolean singleValue;
|
||||||
|
|
||||||
|
private boolean betweenValue;
|
||||||
|
|
||||||
|
private boolean listValue;
|
||||||
|
|
||||||
|
private String typeHandler;
|
||||||
|
|
||||||
|
public String getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSecondValue() {
|
||||||
|
return secondValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoValue() {
|
||||||
|
return noValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingleValue() {
|
||||||
|
return singleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBetweenValue() {
|
||||||
|
return betweenValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isListValue() {
|
||||||
|
return listValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeHandler() {
|
||||||
|
return typeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criterion(String condition) {
|
||||||
|
super();
|
||||||
|
this.condition = condition;
|
||||||
|
this.typeHandler = null;
|
||||||
|
this.noValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criterion(String condition, Object value, String typeHandler) {
|
||||||
|
super();
|
||||||
|
this.condition = condition;
|
||||||
|
this.value = value;
|
||||||
|
this.typeHandler = typeHandler;
|
||||||
|
if (value instanceof List<?>) {
|
||||||
|
this.listValue = true;
|
||||||
|
} else {
|
||||||
|
this.singleValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criterion(String condition, Object value) {
|
||||||
|
this(condition, value, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||||
|
super();
|
||||||
|
this.condition = condition;
|
||||||
|
this.value = value;
|
||||||
|
this.secondValue = secondValue;
|
||||||
|
this.typeHandler = typeHandler;
|
||||||
|
this.betweenValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Criterion(String condition, Object value, Object secondValue) {
|
||||||
|
this(condition, value, secondValue, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,14 +6,19 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.UserQueryVO;
|
import club.joylink.rtss.vo.UserQueryVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||||
import club.joylink.rtss.vo.client.user.*;
|
import club.joylink.rtss.vo.client.user.MobileInfoVO;
|
||||||
|
import club.joylink.rtss.vo.client.user.RetrievePwdVO;
|
||||||
|
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.WeChatBindStatusVO;
|
||||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||||
import club.joylink.rtss.vo.user.AccountRegisterVO;
|
import club.joylink.rtss.vo.user.AccountRegisterVO;
|
||||||
import club.joylink.rtss.vo.wx.WmUserSession;
|
import club.joylink.rtss.vo.wx.WmUserSession;
|
||||||
import java.util.Map;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
public interface ISysUserService {
|
public interface ISysUserService {
|
||||||
|
|
||||||
|
@ -337,7 +342,7 @@ public interface ISysUserService {
|
||||||
*/
|
*/
|
||||||
List<AccountVO> queryAdminsAndSuperAdmins();
|
List<AccountVO> queryAdminsAndSuperAdmins();
|
||||||
|
|
||||||
AccountVO queryOrCreateThirdAccount(String parentAccount, String account);
|
AccountVO queryOrCreateThirdAccount(String parentAccount, String account, @NotEmpty String name);
|
||||||
|
|
||||||
AccountVO getThirdAccount(String account);
|
AccountVO getThirdAccount(String account);
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,25 @@ import club.joylink.rtss.constants.SystemEnv;
|
||||||
import club.joylink.rtss.dao.LearnCommentDAO;
|
import club.joylink.rtss.dao.LearnCommentDAO;
|
||||||
import club.joylink.rtss.dao.LearnMessageDAO;
|
import club.joylink.rtss.dao.LearnMessageDAO;
|
||||||
import club.joylink.rtss.dao.LearnPostDAO;
|
import club.joylink.rtss.dao.LearnPostDAO;
|
||||||
import club.joylink.rtss.entity.*;
|
import club.joylink.rtss.entity.LearnComment;
|
||||||
|
import club.joylink.rtss.entity.LearnCommentExample;
|
||||||
|
import club.joylink.rtss.entity.LearnMessage;
|
||||||
|
import club.joylink.rtss.entity.LearnMessageExample;
|
||||||
|
import club.joylink.rtss.entity.LearnPost;
|
||||||
|
import club.joylink.rtss.entity.LearnPostExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.client.learn.*;
|
import club.joylink.rtss.vo.client.learn.LearnCommentUpdateVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnCommentVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnCreateVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnMessageUpdateVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnPostCreateVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnPostUpdateVO;
|
||||||
|
import club.joylink.rtss.vo.client.learn.LearnPostVO;
|
||||||
import club.joylink.rtss.vo.client.post.LearnMessageCreateVO;
|
import club.joylink.rtss.vo.client.post.LearnMessageCreateVO;
|
||||||
import club.joylink.rtss.vo.client.post.LearnMessagePagedQueryVO;
|
import club.joylink.rtss.vo.client.post.LearnMessagePagedQueryVO;
|
||||||
import club.joylink.rtss.vo.client.post.LearnMessageVO;
|
import club.joylink.rtss.vo.client.post.LearnMessageVO;
|
||||||
|
@ -22,362 +33,374 @@ import club.joylink.rtss.wechat.MiniProgramService;
|
||||||
import club.joylink.rtss.wechat.vo.WxError;
|
import club.joylink.rtss.wechat.vo.WxError;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class LearnService implements ILearnService {
|
public class LearnService implements ILearnService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LearnPostDAO learnPostDAO;
|
private LearnPostDAO learnPostDAO;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LearnCommentDAO learnCommentDAO;
|
private LearnCommentDAO learnCommentDAO;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService iSysUserService;
|
private ISysUserService iSysUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplate restTemplate;
|
private WeChatConfig weChatConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WeChatConfig weChatConfig;
|
private MiniProgramService miniProgramService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MiniProgramService miniProgramService;
|
private LearnMessageDAO learnMessageDAO;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LearnMessageDAO learnMessageDAO;
|
private OtherConfig otherConfig;
|
||||||
|
|
||||||
@Autowired
|
@Override
|
||||||
private OtherConfig otherConfig;
|
public PageVO<LearnPostVO> queryPagedPost(LearnPostPagedQueryVO queryVO) {
|
||||||
|
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||||
@Override
|
LearnPostExample example = new LearnPostExample();
|
||||||
public PageVO<LearnPostVO> queryPagedPost(LearnPostPagedQueryVO queryVO) {
|
if (queryVO.getProject() != null) {
|
||||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
example.createCriteria().andProjectEqualTo(queryVO.getProject());
|
||||||
LearnPostExample example = new LearnPostExample();
|
|
||||||
if (queryVO.getProject() != null) {
|
|
||||||
example.createCriteria().andProjectEqualTo(queryVO.getProject());
|
|
||||||
}
|
|
||||||
Page<LearnPost> page = (Page<LearnPost>) learnPostDAO.selectByExample(example);
|
|
||||||
List<LearnPostVO> vos = page.getResult().stream().map(LearnPostVO::new).collect(Collectors.toList());
|
|
||||||
return PageVO.convert(page, vos);
|
|
||||||
}
|
}
|
||||||
|
Page<LearnPost> page = (Page<LearnPost>) learnPostDAO.selectByExample(example);
|
||||||
|
List<LearnPostVO> vos = page.getResult().stream().map(LearnPostVO::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return PageVO.convert(page, vos);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createPost(LearnPostCreateVO createVO, AccountVO user) {
|
public Long createPost(LearnPostCreateVO createVO, AccountVO user) {
|
||||||
//校验
|
//校验
|
||||||
String title = createVO.getTitle();
|
String title = createVO.getTitle();
|
||||||
String project = createVO.getProject();
|
String project = createVO.getProject();
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(title, "名称不能为空");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(title, "名称不能为空");
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(project, "所属项目不能为空");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(project, "所属项目不能为空");
|
||||||
confirmPostIsNotExist(project);
|
confirmPostIsNotExist(project);
|
||||||
//添加
|
//添加
|
||||||
LearnPost post = new LearnPost();
|
LearnPost post = new LearnPost();
|
||||||
post.setProject(project);
|
post.setProject(project);
|
||||||
post.setTitle(title);
|
post.setTitle(title);
|
||||||
post.setCreatorId(user.getId());
|
post.setCreatorId(user.getId());
|
||||||
post.setCreateTime(LocalDateTime.now());
|
post.setCreateTime(LocalDateTime.now());
|
||||||
post.setTopping(false);
|
post.setTopping(false);
|
||||||
post.setLike(0);
|
post.setLike(0);
|
||||||
post.setUnlike(0);
|
post.setUnlike(0);
|
||||||
learnPostDAO.insert(post);
|
learnPostDAO.insert(post);
|
||||||
return post.getId();
|
return post.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void likePost(Long postId, AccountVO accountVO) {
|
public void likePost(Long postId, AccountVO accountVO) {
|
||||||
LearnPost post = getPostEntity(postId);
|
LearnPost post = getPostEntity(postId);
|
||||||
post.setLike(post.getLike() + 1);
|
post.setLike(post.getLike() + 1);
|
||||||
learnPostDAO.updateByPrimaryKey(post);
|
learnPostDAO.updateByPrimaryKey(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void unlikePost(Long postId, AccountVO accountVO) {
|
public void unlikePost(Long postId, AccountVO accountVO) {
|
||||||
LearnPost post = getPostEntity(postId);
|
LearnPost post = getPostEntity(postId);
|
||||||
post.setUnlike(post.getUnlike() + 1);
|
post.setUnlike(post.getUnlike() + 1);
|
||||||
learnPostDAO.updateByPrimaryKey(post);
|
learnPostDAO.updateByPrimaryKey(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LearnPostVO getPostInfo(Long postId) {
|
public LearnPostVO getPostInfo(Long postId) {
|
||||||
LearnPost post = getPostEntity(postId);
|
LearnPost post = getPostEntity(postId);
|
||||||
LearnPostVO postVO = new LearnPostVO(post);
|
LearnPostVO postVO = new LearnPostVO(post);
|
||||||
// 用户昵称
|
// 用户昵称
|
||||||
AccountVO user = iSysUserService.findUserById(post.getCreatorId());
|
AccountVO user = iSysUserService.findUserById(post.getCreatorId());
|
||||||
postVO.setUserNickname(user.getNickname());
|
postVO.setUserNickname(user.getNickname());
|
||||||
postVO.setAvatarPath(user.getAvatarPath());
|
postVO.setAvatarPath(user.getAvatarPath());
|
||||||
return postVO;
|
return postVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageVO<LearnCommentVO> pagedQueryComment(Long messageId, PageQueryVO queryVO) {
|
public PageVO<LearnCommentVO> pagedQueryComment(Long messageId, PageQueryVO queryVO) {
|
||||||
checkMessageExist(messageId);
|
checkMessageExist(messageId);
|
||||||
List<LearnCommentVO> commentVOList = new ArrayList<>();
|
List<LearnCommentVO> commentVOList = new ArrayList<>();
|
||||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||||
LearnCommentExample commentExample = new LearnCommentExample();
|
LearnCommentExample commentExample = new LearnCommentExample();
|
||||||
commentExample.setOrderByClause("id");
|
commentExample.setOrderByClause("id");
|
||||||
commentExample.createCriteria().andMessageIdEqualTo(messageId);
|
commentExample.createCriteria().andMessageIdEqualTo(messageId);
|
||||||
Page<LearnComment> page = (Page<LearnComment>) learnCommentDAO.selectByExample(commentExample);
|
Page<LearnComment> page = (Page<LearnComment>) learnCommentDAO.selectByExample(commentExample);
|
||||||
page.getResult().forEach(comment -> commentVOList.add(convertComment(comment)));
|
page.getResult().forEach(comment -> commentVOList.add(convertComment(comment)));
|
||||||
return PageVO.convert(page, commentVOList);
|
return PageVO.convert(page, commentVOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LearnCommentVO> queryCommentList(Long messageId) {
|
public List<LearnCommentVO> queryCommentList(Long messageId) {
|
||||||
LearnCommentExample commentExample = new LearnCommentExample();
|
LearnCommentExample commentExample = new LearnCommentExample();
|
||||||
commentExample.createCriteria().andMessageIdEqualTo(messageId);
|
commentExample.createCriteria().andMessageIdEqualTo(messageId);
|
||||||
List<LearnComment> comments = learnCommentDAO.selectByExample(commentExample);
|
List<LearnComment> comments = learnCommentDAO.selectByExample(commentExample);
|
||||||
List<LearnCommentVO> commentVOList = new ArrayList<>();
|
List<LearnCommentVO> commentVOList = new ArrayList<>();
|
||||||
comments.forEach(comment -> commentVOList.add(convertComment(comment)));
|
comments.forEach(comment -> commentVOList.add(convertComment(comment)));
|
||||||
return commentVOList;
|
return commentVOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回复数据完善
|
* 回复数据完善
|
||||||
*
|
*
|
||||||
* @param comment
|
* @param comment
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private LearnCommentVO convertComment(LearnComment comment) {
|
private LearnCommentVO convertComment(LearnComment comment) {
|
||||||
LearnCommentVO commentVO = new LearnCommentVO(comment);
|
LearnCommentVO commentVO = new LearnCommentVO(comment);
|
||||||
// 用户昵称
|
// 用户昵称
|
||||||
if (comment.getCreatorId() != null) {
|
if (comment.getCreatorId() != null) {
|
||||||
String nickname = iSysUserService.findUserById(comment.getCreatorId()).getNickname();
|
String nickname = iSysUserService.findUserById(comment.getCreatorId()).getNickname();
|
||||||
commentVO.setUserNickname(nickname);
|
commentVO.setUserNickname(nickname);
|
||||||
}
|
|
||||||
// 回复的用户的昵称
|
|
||||||
if (comment.getParentId() != null) {
|
|
||||||
commentVO.setReplyUserNickName(iSysUserService.findUserById(comment.getParentId()).getNickname());
|
|
||||||
}
|
|
||||||
// 回复数
|
|
||||||
LearnCommentExample learnCommentExample = new LearnCommentExample();
|
|
||||||
learnCommentExample.createCriteria().andMessageIdEqualTo(comment.getMessageId()).andRootIdEqualTo(comment.getId());
|
|
||||||
commentVO.setCommentCount(learnCommentDAO.countByExample(learnCommentExample));
|
|
||||||
return commentVO;
|
|
||||||
}
|
}
|
||||||
|
// 回复的用户的昵称
|
||||||
|
if (comment.getParentId() != null) {
|
||||||
|
commentVO.setReplyUserNickName(
|
||||||
|
iSysUserService.findUserById(comment.getParentId()).getNickname());
|
||||||
|
}
|
||||||
|
// 回复数
|
||||||
|
LearnCommentExample learnCommentExample = new LearnCommentExample();
|
||||||
|
learnCommentExample.createCriteria().andMessageIdEqualTo(comment.getMessageId())
|
||||||
|
.andRootIdEqualTo(comment.getId());
|
||||||
|
commentVO.setCommentCount(learnCommentDAO.countByExample(learnCommentExample));
|
||||||
|
return commentVO;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addComment(Long messageId, LearnCreateVO commentCreateVO, AccountVO accountVO) {
|
public void addComment(Long messageId, LearnCreateVO commentCreateVO, AccountVO accountVO) {
|
||||||
checkMessageExist(messageId);
|
checkMessageExist(messageId);
|
||||||
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
||||||
this.checkContent(commentCreateVO.getContent());
|
this.checkContent(commentCreateVO.getContent());
|
||||||
}
|
|
||||||
LearnComment comment = new LearnComment();
|
|
||||||
comment.setContent(commentCreateVO.getContent());
|
|
||||||
comment.setMessageId(messageId);
|
|
||||||
comment.setCreatorId(accountVO.getId());
|
|
||||||
comment.setCreateTime(LocalDateTime.now());
|
|
||||||
learnCommentDAO.insertSelective(comment);
|
|
||||||
}
|
}
|
||||||
|
LearnComment comment = new LearnComment();
|
||||||
|
comment.setContent(commentCreateVO.getContent());
|
||||||
|
comment.setMessageId(messageId);
|
||||||
|
comment.setCreatorId(accountVO.getId());
|
||||||
|
comment.setCreateTime(LocalDateTime.now());
|
||||||
|
learnCommentDAO.insertSelective(comment);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addComment(Long messageId, Long commentId, LearnCreateVO postCreateVO, AccountVO accountVO) {
|
public void addComment(Long messageId, Long commentId, LearnCreateVO postCreateVO,
|
||||||
checkMessageExist(messageId);
|
AccountVO accountVO) {
|
||||||
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
checkMessageExist(messageId);
|
||||||
this.checkContent(postCreateVO.getContent());
|
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
||||||
}
|
this.checkContent(postCreateVO.getContent());
|
||||||
LearnComment comment = new LearnComment();
|
|
||||||
comment.setContent(postCreateVO.getContent());
|
|
||||||
comment.setMessageId(messageId);
|
|
||||||
LearnComment parentComment = learnCommentDAO.selectByPrimaryKey(commentId);
|
|
||||||
if (Objects.isNull(parentComment.getRootId())) { // 对评论的回复
|
|
||||||
comment.setRootId(commentId);
|
|
||||||
} else { // 对回复的回复
|
|
||||||
comment.setRootId(parentComment.getRootId());
|
|
||||||
}
|
|
||||||
comment.setParentId(parentComment.getCreatorId());
|
|
||||||
comment.setCreatorId(accountVO.getId());
|
|
||||||
comment.setCreateTime(LocalDateTime.now());
|
|
||||||
learnCommentDAO.insertSelective(comment);
|
|
||||||
}
|
}
|
||||||
|
LearnComment comment = new LearnComment();
|
||||||
|
comment.setContent(postCreateVO.getContent());
|
||||||
|
comment.setMessageId(messageId);
|
||||||
|
LearnComment parentComment = learnCommentDAO.selectByPrimaryKey(commentId);
|
||||||
|
if (Objects.isNull(parentComment.getRootId())) { // 对评论的回复
|
||||||
|
comment.setRootId(commentId);
|
||||||
|
} else { // 对回复的回复
|
||||||
|
comment.setRootId(parentComment.getRootId());
|
||||||
|
}
|
||||||
|
comment.setParentId(parentComment.getCreatorId());
|
||||||
|
comment.setCreatorId(accountVO.getId());
|
||||||
|
comment.setCreateTime(LocalDateTime.now());
|
||||||
|
learnCommentDAO.insertSelective(comment);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void likeComment(Long commentId, AccountVO accountVO) {
|
public void likeComment(Long commentId, AccountVO accountVO) {
|
||||||
LearnComment comment = getCommentEntity(commentId);
|
LearnComment comment = getCommentEntity(commentId);
|
||||||
comment.setLike(comment.getLike() + 1);
|
comment.setLike(comment.getLike() + 1);
|
||||||
learnCommentDAO.updateByPrimaryKey(comment);
|
learnCommentDAO.updateByPrimaryKey(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void unlikeComment(Long commentId, AccountVO accountVO) {
|
public void unlikeComment(Long commentId, AccountVO accountVO) {
|
||||||
LearnComment comment = getCommentEntity(commentId);
|
LearnComment comment = getCommentEntity(commentId);
|
||||||
comment.setUnlike(comment.getUnlike() + 1);
|
comment.setUnlike(comment.getUnlike() + 1);
|
||||||
learnCommentDAO.updateByPrimaryKey(comment);
|
learnCommentDAO.updateByPrimaryKey(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void top(Long postId, AccountVO accountVO) {
|
public void top(Long postId, AccountVO accountVO) {
|
||||||
LearnPost post = topCheck(postId, accountVO);
|
LearnPost post = topCheck(postId, accountVO);
|
||||||
post.setTopping(true);
|
post.setTopping(true);
|
||||||
learnPostDAO.updateByPrimaryKey(post);
|
learnPostDAO.updateByPrimaryKey(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unTop(Long postId, AccountVO accountVO) {
|
public void unTop(Long postId, AccountVO accountVO) {
|
||||||
LearnPost post = topCheck(postId, accountVO);
|
LearnPost post = topCheck(postId, accountVO);
|
||||||
post.setTopping(false);
|
post.setTopping(false);
|
||||||
learnPostDAO.updateByPrimaryKey(post);
|
learnPostDAO.updateByPrimaryKey(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deletePost(Long postId, AccountVO accountVO) {
|
public void deletePost(Long postId, AccountVO accountVO) {
|
||||||
topCheck(postId, accountVO);
|
topCheck(postId, accountVO);
|
||||||
//删除留言
|
//删除留言
|
||||||
LearnMessageExample messageExample = new LearnMessageExample();
|
LearnMessageExample messageExample = new LearnMessageExample();
|
||||||
messageExample.createCriteria().andPostIdEqualTo(postId);
|
messageExample.createCriteria().andPostIdEqualTo(postId);
|
||||||
List<Long> messageIds = learnMessageDAO.selectByExample(messageExample).stream().map(LearnMessage::getId).collect(Collectors.toList());
|
List<Long> messageIds = learnMessageDAO.selectByExample(messageExample).stream()
|
||||||
learnMessageDAO.deleteByExample(messageExample);
|
.map(LearnMessage::getId).collect(Collectors.toList());
|
||||||
//删除评论
|
learnMessageDAO.deleteByExample(messageExample);
|
||||||
LearnCommentExample commentExample = new LearnCommentExample();
|
//删除评论
|
||||||
commentExample.createCriteria().andMessageIdIn(messageIds);
|
LearnCommentExample commentExample = new LearnCommentExample();
|
||||||
learnCommentDAO.deleteByExample(commentExample);
|
commentExample.createCriteria().andMessageIdIn(messageIds);
|
||||||
learnPostDAO.deleteByPrimaryKey(postId);
|
learnCommentDAO.deleteByExample(commentExample);
|
||||||
}
|
learnPostDAO.deleteByPrimaryKey(postId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adminDeleteComment(Long commentId, AccountVO user) {
|
public void adminDeleteComment(Long commentId, AccountVO user) {
|
||||||
iSysUserService.confirmAdmin(user);
|
iSysUserService.confirmAdmin(user);
|
||||||
learnCommentDAO.deleteByPrimaryKey(commentId);
|
learnCommentDAO.deleteByPrimaryKey(commentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userDeleteComment(Long commentId, AccountVO user) {
|
public void userDeleteComment(Long commentId, AccountVO user) {
|
||||||
LearnComment comment = getCommentEntity(commentId);
|
LearnComment comment = getCommentEntity(commentId);
|
||||||
if (!comment.getCreatorId().equals(user.getId())) {
|
if (!comment.getCreatorId().equals(user.getId())) {
|
||||||
log.error(String.format("用户[%s]意外尝试删除别人的评论[%s]", user.getId(), commentId));
|
log.error(String.format("用户[%s]意外尝试删除别人的评论[%s]", user.getId(), commentId));
|
||||||
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的评论");
|
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的评论");
|
||||||
}
|
|
||||||
learnCommentDAO.deleteByPrimaryKey(commentId);
|
|
||||||
}
|
}
|
||||||
|
learnCommentDAO.deleteByPrimaryKey(commentId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createMessage(LearnMessageCreateVO messageCreateVO, AccountVO user) {
|
public long createMessage(LearnMessageCreateVO messageCreateVO, AccountVO user) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(messageCreateVO.getContent()),
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||||
"内容不能空白");
|
StringUtils.hasText(messageCreateVO.getContent()),
|
||||||
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
"内容不能空白");
|
||||||
this.checkContent(messageCreateVO.getContent());
|
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
|
||||||
}
|
this.checkContent(messageCreateVO.getContent());
|
||||||
LearnMessage message = messageCreateVO.convert2DB(user.getId());
|
|
||||||
learnMessageDAO.insert(message);
|
|
||||||
LearnMessageExample example = new LearnMessageExample();
|
|
||||||
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
|
|
||||||
return learnMessageDAO.countByExample(example);
|
|
||||||
}
|
}
|
||||||
|
LearnMessage message = messageCreateVO.convert2DB(user.getId());
|
||||||
|
learnMessageDAO.insert(message);
|
||||||
|
LearnMessageExample example = new LearnMessageExample();
|
||||||
|
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
|
||||||
|
return learnMessageDAO.countByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageVO<LearnMessageVO> pagedQueryMessageByPostId(Long postId, LearnMessagePagedQueryVO queryVO) {
|
public PageVO<LearnMessageVO> pagedQueryMessageByPostId(Long postId,
|
||||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
LearnMessagePagedQueryVO queryVO) {
|
||||||
Page<LearnMessageVO> page = (Page<LearnMessageVO>) learnMessageDAO.select(postId, queryVO);
|
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||||
for (LearnMessageVO vo : page.getResult()) {
|
Page<LearnMessageVO> page = (Page<LearnMessageVO>) learnMessageDAO.select(postId, queryVO);
|
||||||
vo.setComments(pagedQueryComment(vo.getId(), new PageQueryVO(1, 3)));
|
for (LearnMessageVO vo : page.getResult()) {
|
||||||
}
|
vo.setComments(pagedQueryComment(vo.getId(), new PageQueryVO(1, 3)));
|
||||||
return PageVO.convert(page);
|
|
||||||
}
|
}
|
||||||
|
return PageVO.convert(page);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adminDeleteMessage(Long messageId, AccountVO user) {
|
public void adminDeleteMessage(Long messageId, AccountVO user) {
|
||||||
iSysUserService.confirmAdmin(user);
|
iSysUserService.confirmAdmin(user);
|
||||||
deleteMessage(messageId);
|
deleteMessage(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userDeleteMessage(Long messageId, AccountVO user) {
|
public void userDeleteMessage(Long messageId, AccountVO user) {
|
||||||
LearnMessage message = getMessageEntity(messageId);
|
LearnMessage message = getMessageEntity(messageId);
|
||||||
if (!message.getCreatorId().equals(user.getId())) {
|
if (!message.getCreatorId().equals(user.getId())) {
|
||||||
log.error(String.format("用户[%s]意外尝试删除别人的留言[%s]", user.getId(), messageId));
|
log.error(String.format("用户[%s]意外尝试删除别人的留言[%s]", user.getId(), messageId));
|
||||||
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的留言");
|
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的留言");
|
||||||
}
|
|
||||||
deleteMessage(messageId);
|
|
||||||
}
|
}
|
||||||
|
deleteMessage(messageId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LearnPostVO queryPost(String project) {
|
public LearnPostVO queryPost(String project) {
|
||||||
LearnPostExample example = new LearnPostExample();
|
LearnPostExample example = new LearnPostExample();
|
||||||
example.createCriteria().andProjectEqualTo(project);
|
example.createCriteria().andProjectEqualTo(project);
|
||||||
List<LearnPost> learnPosts = learnPostDAO.selectByExample(example);
|
List<LearnPost> learnPosts = learnPostDAO.selectByExample(example);
|
||||||
if (CollectionUtils.isEmpty(learnPosts)) {
|
if (CollectionUtils.isEmpty(learnPosts)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
return new LearnPostVO(learnPosts.get(0));
|
|
||||||
}
|
}
|
||||||
|
return new LearnPostVO(learnPosts.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageVO<LearnMessageVO> pagedQueryMessageByProject(String project, LearnMessagePagedQueryVO queryVO) {
|
public PageVO<LearnMessageVO> pagedQueryMessageByProject(String project,
|
||||||
LearnPostVO post = queryPost(project);
|
LearnMessagePagedQueryVO queryVO) {
|
||||||
if (post == null) {
|
LearnPostVO post = queryPost(project);
|
||||||
log.error(String.format("项目[%s]的留言板不存在", project));
|
if (post == null) {
|
||||||
throw new SimulationException(SimulationExceptionType.System_Fault, "该项目的留言板不存在");
|
log.error(String.format("项目[%s]的留言板不存在", project));
|
||||||
}
|
throw new SimulationException(SimulationExceptionType.System_Fault, "该项目的留言板不存在");
|
||||||
return pagedQueryMessageByPostId(post.getId(), queryVO);
|
|
||||||
}
|
}
|
||||||
|
return pagedQueryMessageByPostId(post.getId(), queryVO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePost(Long postId, LearnPostUpdateVO updateVO, AccountVO user) {
|
public void updatePost(Long postId, LearnPostUpdateVO updateVO, AccountVO user) {
|
||||||
iSysUserService.confirmAdmin(user);
|
iSysUserService.confirmAdmin(user);
|
||||||
LearnPost entity = getPostEntity(postId);
|
LearnPost entity = getPostEntity(postId);
|
||||||
if (Objects.equals(updateVO.getTitle(), entity.getTitle()))
|
if (Objects.equals(updateVO.getTitle(), entity.getTitle())) {
|
||||||
return;
|
return;
|
||||||
entity.setTitle(updateVO.getTitle());
|
|
||||||
learnPostDAO.updateByPrimaryKey(entity);
|
|
||||||
}
|
}
|
||||||
|
entity.setTitle(updateVO.getTitle());
|
||||||
|
learnPostDAO.updateByPrimaryKey(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long cgyCreateMessage(LearnMessageCreateVO messageCreateVO) {
|
public long cgyCreateMessage(LearnMessageCreateVO messageCreateVO) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(messageCreateVO.getContent()),
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||||
"内容不能空白");
|
StringUtils.hasText(messageCreateVO.getContent()),
|
||||||
LearnMessage message = messageCreateVO.convert2DB(1L);
|
"内容不能空白");
|
||||||
message.setCreatorId(null);
|
LearnMessage message = messageCreateVO.convert2DB(1L);
|
||||||
message.setUserName(messageCreateVO.getUserName());
|
message.setCreatorId(null);
|
||||||
learnMessageDAO.insert(message);
|
message.setUserName(messageCreateVO.getUserName());
|
||||||
LearnMessageExample example = new LearnMessageExample();
|
learnMessageDAO.insert(message);
|
||||||
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
|
LearnMessageExample example = new LearnMessageExample();
|
||||||
return learnMessageDAO.countByExample(example);
|
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
|
||||||
}
|
return learnMessageDAO.countByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cgyAddComment(Long messageId, LearnCreateVO commentCreateVO) {
|
public void cgyAddComment(Long messageId, LearnCreateVO commentCreateVO) {
|
||||||
checkMessageExist(messageId);
|
checkMessageExist(messageId);
|
||||||
LearnComment comment = new LearnComment();
|
LearnComment comment = new LearnComment();
|
||||||
comment.setContent(commentCreateVO.getContent());
|
comment.setContent(commentCreateVO.getContent());
|
||||||
comment.setMessageId(messageId);
|
comment.setMessageId(messageId);
|
||||||
comment.setCreateTime(LocalDateTime.now());
|
comment.setCreateTime(LocalDateTime.now());
|
||||||
comment.setUserName(commentCreateVO.getUserName());
|
comment.setUserName(commentCreateVO.getUserName());
|
||||||
learnCommentDAO.insertSelective(comment);
|
learnCommentDAO.insertSelective(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adminUpdateMessage(LearnMessageUpdateVO messageUpdateVO) {
|
public void adminUpdateMessage(LearnMessageUpdateVO messageUpdateVO) {
|
||||||
LearnMessage messageEntity = getMessageEntity(messageUpdateVO.getId());
|
LearnMessage messageEntity = getMessageEntity(messageUpdateVO.getId());
|
||||||
messageEntity.setContent(messageUpdateVO.getContent());
|
messageEntity.setContent(messageUpdateVO.getContent());
|
||||||
messageEntity.setCreateTime(messageUpdateVO.getCreateTime());
|
messageEntity.setCreateTime(messageUpdateVO.getCreateTime());
|
||||||
learnMessageDAO.updateByPrimaryKey(messageEntity);
|
learnMessageDAO.updateByPrimaryKey(messageEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adminUpdateComment(LearnCommentUpdateVO commentUpdateVO) {
|
public void adminUpdateComment(LearnCommentUpdateVO commentUpdateVO) {
|
||||||
LearnComment commentEntity = getCommentEntity(commentUpdateVO.getId());
|
LearnComment commentEntity = getCommentEntity(commentUpdateVO.getId());
|
||||||
commentEntity.setMessageId(commentUpdateVO.getMessageId());
|
commentEntity.setMessageId(commentUpdateVO.getMessageId());
|
||||||
commentEntity.setContent(commentUpdateVO.getContent());
|
commentEntity.setContent(commentUpdateVO.getContent());
|
||||||
commentEntity.setCreatorId(commentUpdateVO.getCreatorId());
|
commentEntity.setCreatorId(commentUpdateVO.getCreatorId());
|
||||||
commentEntity.setCreateTime(commentUpdateVO.getCreateTime());
|
commentEntity.setCreateTime(commentUpdateVO.getCreateTime());
|
||||||
learnCommentDAO.updateByPrimaryKey(commentEntity);
|
learnCommentDAO.updateByPrimaryKey(commentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Transactional
|
// @Transactional
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -400,50 +423,55 @@ public class LearnService implements ILearnService {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void cgyUpdateMessageTime() {
|
public void cgyUpdateMessageTime() {
|
||||||
LearnMessageExample example = new LearnMessageExample();
|
LearnMessageExample example = new LearnMessageExample();
|
||||||
example.createCriteria().andPostIdEqualTo(27L);
|
example.createCriteria().andPostIdEqualTo(27L);
|
||||||
List<LearnMessage> allMessage = learnMessageDAO.selectByExample(example);
|
List<LearnMessage> allMessage = learnMessageDAO.selectByExample(example);
|
||||||
//删重复数据
|
//删重复数据
|
||||||
List<LearnMessage> list = allMessage.stream().collect(Collectors.toMap(LearnMessage::getContent, Function.identity(), (old, newValue) -> old))
|
List<LearnMessage> list = allMessage.stream().collect(
|
||||||
.values().stream().sorted(Comparator.comparingLong(LearnMessage::getId)).collect(Collectors.toList());
|
Collectors.toMap(LearnMessage::getContent, Function.identity(), (old, newValue) -> old))
|
||||||
HashSet<LearnMessage> distinctSet = new HashSet<>(list);
|
.values().stream().sorted(Comparator.comparingLong(LearnMessage::getId))
|
||||||
List<Long> deleteIds = allMessage.stream().filter(message -> !distinctSet.contains(message)).map(LearnMessage::getId).collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (!CollectionUtils.isEmpty(deleteIds)) {
|
HashSet<LearnMessage> distinctSet = new HashSet<>(list);
|
||||||
example.clear();
|
List<Long> deleteIds = allMessage.stream().filter(message -> !distinctSet.contains(message))
|
||||||
example.createCriteria().andIdIn(deleteIds);
|
.map(LearnMessage::getId).collect(Collectors.toList());
|
||||||
learnMessageDAO.deleteByExample(example);
|
if (!CollectionUtils.isEmpty(deleteIds)) {
|
||||||
}
|
example.clear();
|
||||||
//修改时间
|
example.createCriteria().andIdIn(deleteIds);
|
||||||
int day = 365 * 4;
|
learnMessageDAO.deleteByExample(example);
|
||||||
Random random = new Random();
|
|
||||||
List<Integer> dayOffsetList = new ArrayList<>();
|
|
||||||
for (LearnMessage ignored : list) {
|
|
||||||
dayOffsetList.add(random.nextInt(day));
|
|
||||||
}
|
|
||||||
dayOffsetList.sort((i1, i2) -> i2 - i1);
|
|
||||||
Map<Integer, Long> dayCountMap = dayOffsetList.stream().collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()));
|
|
||||||
int startIndex = 0;
|
|
||||||
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
|
||||||
for (Integer dayOffset : dayCountMap.keySet()) {
|
|
||||||
List<Integer> secondsOffsetList = new ArrayList<>();
|
|
||||||
Long dayCount = dayCountMap.get(dayOffset);
|
|
||||||
for (int i = 0; i < dayCount; i++) {
|
|
||||||
secondsOffsetList.add(random.nextInt(24 * 3600 - 8 * 3600) + 8 * 3600);
|
|
||||||
secondsOffsetList.sort(Integer::compareTo);
|
|
||||||
}
|
|
||||||
for (int i = startIndex; i < startIndex + dayCount; i++) {
|
|
||||||
LearnMessage message = list.get(i);
|
|
||||||
message.setCreateTime(now.minusDays(dayOffset).plusSeconds(secondsOffsetList.get(i - startIndex)));
|
|
||||||
learnMessageDAO.updateByPrimaryKey(message);
|
|
||||||
}
|
|
||||||
startIndex += dayCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//修改时间
|
||||||
|
int day = 365 * 4;
|
||||||
|
Random random = new Random();
|
||||||
|
List<Integer> dayOffsetList = new ArrayList<>();
|
||||||
|
for (LearnMessage ignored : list) {
|
||||||
|
dayOffsetList.add(random.nextInt(day));
|
||||||
|
}
|
||||||
|
dayOffsetList.sort((i1, i2) -> i2 - i1);
|
||||||
|
Map<Integer, Long> dayCountMap = dayOffsetList.stream().collect(
|
||||||
|
Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()));
|
||||||
|
int startIndex = 0;
|
||||||
|
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
||||||
|
for (Integer dayOffset : dayCountMap.keySet()) {
|
||||||
|
List<Integer> secondsOffsetList = new ArrayList<>();
|
||||||
|
Long dayCount = dayCountMap.get(dayOffset);
|
||||||
|
for (int i = 0; i < dayCount; i++) {
|
||||||
|
secondsOffsetList.add(random.nextInt(24 * 3600 - 8 * 3600) + 8 * 3600);
|
||||||
|
secondsOffsetList.sort(Integer::compareTo);
|
||||||
|
}
|
||||||
|
for (int i = startIndex; i < startIndex + dayCount; i++) {
|
||||||
|
LearnMessage message = list.get(i);
|
||||||
|
message.setCreateTime(
|
||||||
|
now.minusDays(dayOffset).plusSeconds(secondsOffsetList.get(i - startIndex)));
|
||||||
|
learnMessageDAO.updateByPrimaryKey(message);
|
||||||
|
}
|
||||||
|
startIndex += dayCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public Integer likeMessage(Long messageId) {
|
// public Integer likeMessage(Long messageId) {
|
||||||
// LearnMessageWithBLOBs message = getMessage(messageId);
|
// LearnMessageWithBLOBs message = getMessage(messageId);
|
||||||
// message.setLike(message.getLike() == null ? 0 : message.getLike() + 1);
|
// message.setLike(message.getLike() == null ? 0 : message.getLike() + 1);
|
||||||
|
@ -459,38 +487,38 @@ public class LearnService implements ILearnService {
|
||||||
// return message.getUnlike();
|
// return message.getUnlike();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private LearnComment findCommentEntity(Long commentId) {
|
private LearnComment findCommentEntity(Long commentId) {
|
||||||
return learnCommentDAO.selectByPrimaryKey(commentId);
|
return learnCommentDAO.selectByPrimaryKey(commentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LearnComment getCommentEntity(Long commentId) {
|
private LearnComment getCommentEntity(Long commentId) {
|
||||||
LearnComment comment = findCommentEntity(commentId);
|
LearnComment comment = findCommentEntity(commentId);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(comment,
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(comment,
|
||||||
"该评论不存在或已被删除");
|
"该评论不存在或已被删除");
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteMessage(Long messageId) {
|
private void deleteMessage(Long messageId) {
|
||||||
learnMessageDAO.deleteByPrimaryKey(messageId);
|
learnMessageDAO.deleteByPrimaryKey(messageId);
|
||||||
deleteCommentByMessageId(messageId);
|
deleteCommentByMessageId(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteCommentByMessageId(Long messageId) {
|
private void deleteCommentByMessageId(Long messageId) {
|
||||||
LearnCommentExample example = new LearnCommentExample();
|
LearnCommentExample example = new LearnCommentExample();
|
||||||
example.createCriteria().andMessageIdEqualTo(messageId);
|
example.createCriteria().andMessageIdEqualTo(messageId);
|
||||||
learnCommentDAO.deleteByExample(example);
|
learnCommentDAO.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LearnPost topCheck(Long postId, AccountVO accountVO) {
|
private LearnPost topCheck(Long postId, AccountVO accountVO) {
|
||||||
iSysUserService.confirmAdmin(accountVO);
|
iSysUserService.confirmAdmin(accountVO);
|
||||||
LearnPost post = getPostEntity(postId);
|
LearnPost post = getPostEntity(postId);
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkContent(String content) {
|
private void checkContent(String content) {
|
||||||
WxError wxError = this.miniProgramService.msgSecCheck(content);
|
WxError wxError = this.miniProgramService.msgSecCheck(content);
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(wxError.isError(),
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(wxError.isError(),
|
||||||
String.format("内容校验不通过: [%s]", wxError.toString()));
|
String.format("内容校验不通过: [%s]", wxError.toString()));
|
||||||
// Map<String, String> param = new HashMap<>();
|
// Map<String, String> param = new HashMap<>();
|
||||||
// param.put("content", content);
|
// param.put("content", content);
|
||||||
// WxBaseResp resp = restTemplate.postForObject(weChatConfig.getMsgSecCheckUrl(), param, WxBaseResp.class);
|
// WxBaseResp resp = restTemplate.postForObject(weChatConfig.getMsgSecCheckUrl(), param, WxBaseResp.class);
|
||||||
|
@ -502,44 +530,46 @@ public class LearnService implements ILearnService {
|
||||||
// } else {
|
// } else {
|
||||||
// throw new BusinessException(ExceptionMapping.SERVER_CALL_EXCEPTION);
|
// throw new BusinessException(ExceptionMapping.SERVER_CALL_EXCEPTION);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 留言检查
|
* 留言检查
|
||||||
*/
|
*/
|
||||||
private void checkMessageExist(Long messageId) {
|
private void checkMessageExist(Long messageId) {
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(findMessageEntity(messageId),
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(findMessageEntity(messageId),
|
||||||
String.format("id为[%s]的留言不存在", messageId));
|
String.format("id为[%s]的留言不存在", messageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private LearnMessage findMessageEntity(Long messageId) {
|
private LearnMessage findMessageEntity(Long messageId) {
|
||||||
return learnMessageDAO.selectByPrimaryKey(messageId);
|
return learnMessageDAO.selectByPrimaryKey(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LearnMessage getMessageEntity(Long messageId) {
|
private LearnMessage getMessageEntity(Long messageId) {
|
||||||
LearnMessage message = findMessageEntity(messageId);
|
LearnMessage message = findMessageEntity(messageId);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(message, String.format("id为[%s]的留言不存在", messageId));
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(message,
|
||||||
return message;
|
String.format("id为[%s]的留言不存在", messageId));
|
||||||
}
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
private LearnPost findPostEntity(Long postId) {
|
private LearnPost findPostEntity(Long postId) {
|
||||||
return learnPostDAO.selectByPrimaryKey(postId);
|
return learnPostDAO.selectByPrimaryKey(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LearnPost getPostEntity(Long postId) {
|
private LearnPost getPostEntity(Long postId) {
|
||||||
LearnPost post = findPostEntity(postId);
|
LearnPost post = findPostEntity(postId);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(post);
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(post);
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确认该项目的留言板不存在
|
* 确认该项目的留言板不存在
|
||||||
*/
|
*/
|
||||||
private void confirmPostIsNotExist(String project) {
|
private void confirmPostIsNotExist(String project) {
|
||||||
LearnPostExample example = new LearnPostExample();
|
LearnPostExample example = new LearnPostExample();
|
||||||
example.createCriteria().andProjectEqualTo(project);
|
example.createCriteria().andProjectEqualTo(project);
|
||||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(learnPostDAO.countByExample(example) == 0,
|
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(
|
||||||
String.format("项目[%s]下留言板已存在", project));
|
learnPostDAO.countByExample(example) == 0,
|
||||||
}
|
String.format("项目[%s]下留言板已存在", project));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,12 @@ import club.joylink.rtss.constants.StatusEnum;
|
||||||
import club.joylink.rtss.dao.OrgDAO;
|
import club.joylink.rtss.dao.OrgDAO;
|
||||||
import club.joylink.rtss.dao.SysAccountDAO;
|
import club.joylink.rtss.dao.SysAccountDAO;
|
||||||
import club.joylink.rtss.dao.UserSubscribeMapper;
|
import club.joylink.rtss.dao.UserSubscribeMapper;
|
||||||
import club.joylink.rtss.entity.*;
|
import club.joylink.rtss.entity.Org;
|
||||||
|
import club.joylink.rtss.entity.OrgUser;
|
||||||
|
import club.joylink.rtss.entity.SysAccount;
|
||||||
|
import club.joylink.rtss.entity.SysAccountExample;
|
||||||
|
import club.joylink.rtss.entity.UserSubscribe;
|
||||||
|
import club.joylink.rtss.entity.UserSubscribeExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.services.cache.ICacheService;
|
import club.joylink.rtss.services.cache.ICacheService;
|
||||||
import club.joylink.rtss.services.org.IOrgProjectService;
|
import club.joylink.rtss.services.org.IOrgProjectService;
|
||||||
|
@ -14,10 +19,19 @@ import club.joylink.rtss.services.org.IOrgService;
|
||||||
import club.joylink.rtss.services.org.IOrgUserService;
|
import club.joylink.rtss.services.org.IOrgUserService;
|
||||||
import club.joylink.rtss.util.EncryptUtil;
|
import club.joylink.rtss.util.EncryptUtil;
|
||||||
import club.joylink.rtss.util.RandomGenerator;
|
import club.joylink.rtss.util.RandomGenerator;
|
||||||
import club.joylink.rtss.vo.*;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
|
import club.joylink.rtss.vo.SmsResponse;
|
||||||
|
import club.joylink.rtss.vo.UserQueryVO;
|
||||||
|
import club.joylink.rtss.vo.VdCode;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||||
import club.joylink.rtss.vo.client.user.*;
|
import club.joylink.rtss.vo.client.user.MobileInfoVO;
|
||||||
|
import club.joylink.rtss.vo.client.user.RetrievePwdVO;
|
||||||
|
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.WeChatBindStatusVO;
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||||
import club.joylink.rtss.vo.user.AccountRegisterVO;
|
import club.joylink.rtss.vo.user.AccountRegisterVO;
|
||||||
|
@ -25,6 +39,18 @@ import club.joylink.rtss.vo.wx.WmUserSession;
|
||||||
import club.joylink.rtss.vo.wx.WxUserGet;
|
import club.joylink.rtss.vo.wx.WxUserGet;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -34,13 +60,6 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysUserService implements ISysUserService {
|
public class SysUserService implements ISysUserService {
|
||||||
|
@ -360,7 +379,8 @@ public class SysUserService implements ISysUserService {
|
||||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotHasText(account.getWmOpenId(),
|
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotHasText(account.getWmOpenId(),
|
||||||
String.format("用户[%s]已经绑定微信小程序", account.getNickname()));
|
String.format("用户[%s]已经绑定微信小程序", account.getNickname()));
|
||||||
// 如果之前已经存在绑定,解除之前的绑定
|
// 如果之前已经存在绑定,解除之前的绑定
|
||||||
WmUserSession userSession = this.iWxApiService.getWmUserSession(WxApiService.MiniApp.JoyLink, code);
|
WmUserSession userSession = this.iWxApiService.getWmUserSession(WxApiService.MiniApp.JoyLink,
|
||||||
|
code);
|
||||||
String openid = userSession.getOpenid();
|
String openid = userSession.getOpenid();
|
||||||
SysAccountExample example = new SysAccountExample();
|
SysAccountExample example = new SysAccountExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
|
@ -392,7 +412,8 @@ public class SysUserService implements ISysUserService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
public OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
||||||
SysAccount sysAccount = sysAccountDAO.selectByPrimaryKey(userId);
|
SysAccount sysAccount = sysAccountDAO.selectByPrimaryKey(userId);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(sysAccount, String.format("id为[%s]的用户不存在", userId));
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(sysAccount,
|
||||||
|
String.format("id为[%s]的用户不存在", userId));
|
||||||
AccountVO accountVO = new AccountVO(sysAccount);
|
AccountVO accountVO = new AccountVO(sysAccount);
|
||||||
OrgVO orgVO = iOrgUserService.userBindCompanyManager(accountVO, companyId);
|
OrgVO orgVO = iOrgUserService.userBindCompanyManager(accountVO, companyId);
|
||||||
this.loginSessionManager.updateLoginUser(accountVO);
|
this.loginSessionManager.updateLoginUser(accountVO);
|
||||||
|
@ -655,7 +676,8 @@ public class SysUserService implements ISysUserService {
|
||||||
@Override
|
@Override
|
||||||
public void updateMobile(Long id, UpdateMobileVO updateMobileVO) {
|
public void updateMobile(Long id, UpdateMobileVO updateMobileVO) {
|
||||||
Objects.requireNonNull(id, "用户id不能为空");
|
Objects.requireNonNull(id, "用户id不能为空");
|
||||||
validateMobileVerificationCode(updateMobileVO.getNationCode(), updateMobileVO.getMobile(), updateMobileVO.getValidCode());
|
validateMobileVerificationCode(updateMobileVO.getNationCode(), updateMobileVO.getMobile(),
|
||||||
|
updateMobileVO.getValidCode());
|
||||||
SysAccount account = this.sysAccountDAO.selectByPrimaryKey(id);
|
SysAccount account = this.sysAccountDAO.selectByPrimaryKey(id);
|
||||||
if (Objects.nonNull(account)) {
|
if (Objects.nonNull(account)) {
|
||||||
account.setNationcode(updateMobileVO.getNationCode());
|
account.setNationcode(updateMobileVO.getNationCode());
|
||||||
|
@ -666,7 +688,8 @@ public class SysUserService implements ISysUserService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMobileVerificationCode(String nationCode, String mobile, String verificationCode) {
|
private void validateMobileVerificationCode(String nationCode, String mobile,
|
||||||
|
String verificationCode) {
|
||||||
VdCode vdCode = (VdCode) this.iCacheService.get(nationCode + mobile);
|
VdCode vdCode = (VdCode) this.iCacheService.get(nationCode + mobile);
|
||||||
// 验证验证码
|
// 验证验证码
|
||||||
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
||||||
|
@ -705,16 +728,20 @@ public class SysUserService implements ISysUserService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String sendMobileValidCode(MobileInfoVO mobileInfoVO) {
|
public String sendMobileValidCode(MobileInfoVO mobileInfoVO) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate(), "发送验证码请求未通过");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate(),
|
||||||
|
"发送验证码请求未通过");
|
||||||
String code = RandomGenerator.getByLen(4);
|
String code = RandomGenerator.getByLen(4);
|
||||||
long ts = System.currentTimeMillis();
|
long ts = System.currentTimeMillis();
|
||||||
List<String> params = new ArrayList<>();
|
List<String> params = new ArrayList<>();
|
||||||
params.add(code);
|
params.add(code);
|
||||||
params.add(VdCode.CODE_TIMEOUT + "");
|
params.add(VdCode.CODE_TIMEOUT + "");
|
||||||
SmsResponse resp = this.iSmsService.sendValidateCode(mobileInfoVO.getMobile(), mobileInfoVO.getNationCode(), params, ts);
|
SmsResponse resp = this.iSmsService.sendValidateCode(mobileInfoVO.getMobile(),
|
||||||
|
mobileInfoVO.getNationCode(), params, ts);
|
||||||
BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.assertTrue(resp.getResult() == 0,
|
BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.assertTrue(resp.getResult() == 0,
|
||||||
String.format("短信发送服务调用异常:[result: %s, errmsg: %s]", resp.getResult(), resp.getErrmsg()));
|
String.format("短信发送服务调用异常:[result: %s, errmsg: %s]", resp.getResult(),
|
||||||
iCacheService.putExpired(mobileInfoVO.buildUp(), new VdCode(code, ts), VdCode.CODE_TIMEOUT, TimeUnit.MINUTES);
|
resp.getErrmsg()));
|
||||||
|
iCacheService.putExpired(mobileInfoVO.buildUp(), new VdCode(code, ts), VdCode.CODE_TIMEOUT,
|
||||||
|
TimeUnit.MINUTES);
|
||||||
log.debug(String.format("短息发送手机%s验证码:[%s]", mobileInfoVO.buildUp(), code));
|
log.debug(String.format("短息发送手机%s验证码:[%s]", mobileInfoVO.buildUp(), code));
|
||||||
return EncryptUtil.md5(code);
|
return EncryptUtil.md5(code);
|
||||||
}
|
}
|
||||||
|
@ -729,7 +756,8 @@ public class SysUserService implements ISysUserService {
|
||||||
|
|
||||||
private void updatePwdByMobileVdCode(UpdatePasswordVO updatePasswordVO, SysAccount account) {
|
private void updatePwdByMobileVdCode(UpdatePasswordVO updatePasswordVO, SysAccount account) {
|
||||||
if (Objects.nonNull(account)) {
|
if (Objects.nonNull(account)) {
|
||||||
VdCode vdCode = (VdCode) this.iCacheService.get(account.getNationcode() + account.getMobile());
|
VdCode vdCode = (VdCode) this.iCacheService.get(
|
||||||
|
account.getNationcode() + account.getMobile());
|
||||||
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
|
||||||
// 验证验证码
|
// 验证验证码
|
||||||
vdCode.isValidCode(updatePasswordVO.getVfCode());
|
vdCode.isValidCode(updatePasswordVO.getVfCode());
|
||||||
|
@ -787,7 +815,8 @@ public class SysUserService implements ISysUserService {
|
||||||
SysAccountExample example = new SysAccountExample();
|
SysAccountExample example = new SysAccountExample();
|
||||||
example.createCriteria().andNameLike(String.format("%%%s%%", name));
|
example.createCriteria().andNameLike(String.format("%%%s%%", name));
|
||||||
List<SysAccount> users = sysAccountDAO.selectByExample(example);
|
List<SysAccount> users = sysAccountDAO.selectByExample(example);
|
||||||
List<AccountVO> voList = users.stream().map(account -> new AccountVO(account)).collect(Collectors.toList());
|
List<AccountVO> voList = users.stream().map(account -> new AccountVO(account))
|
||||||
|
.collect(Collectors.toList());
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,7 +829,8 @@ public class SysUserService implements ISysUserService {
|
||||||
@Override
|
@Override
|
||||||
public List<AccountVO> getUsersWithEmail() {
|
public List<AccountVO> getUsersWithEmail() {
|
||||||
SysAccountExample example = new SysAccountExample();
|
SysAccountExample example = new SysAccountExample();
|
||||||
example.createCriteria().andMobileIsNotNull().andNationcodeIsNotNull().andStatusEqualTo(BusinessConsts.STATUS_USE);
|
example.createCriteria().andMobileIsNotNull().andNationcodeIsNotNull()
|
||||||
|
.andStatusEqualTo(BusinessConsts.STATUS_USE);
|
||||||
List<SysAccount> sysUsers = sysAccountDAO.selectByExample(example);
|
List<SysAccount> sysUsers = sysAccountDAO.selectByExample(example);
|
||||||
List<AccountVO> users = sysUsers.stream().map(AccountVO::new).collect(Collectors.toList());
|
List<AccountVO> users = sysUsers.stream().map(AccountVO::new).collect(Collectors.toList());
|
||||||
return users;
|
return users;
|
||||||
|
@ -882,7 +912,8 @@ public class SysUserService implements ISysUserService {
|
||||||
|
|
||||||
private SysAccount getEntity(Long id) {
|
private SysAccount getEntity(Long id) {
|
||||||
SysAccount account = sysAccountDAO.selectByPrimaryKey(id);
|
SysAccount account = sysAccountDAO.selectByPrimaryKey(id);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(account, String.format("id为[%s]的用户不存在", id));
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(account,
|
||||||
|
String.format("id为[%s]的用户不存在", id));
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,7 +924,8 @@ public class SysUserService implements ISysUserService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(AccountCreateVO accountCreateVO) {
|
public void register(AccountCreateVO accountCreateVO) {
|
||||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(this.isSameEmailExist(accountCreateVO.getEmail()));
|
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(
|
||||||
|
this.isSameEmailExist(accountCreateVO.getEmail()));
|
||||||
SysAccount account = accountCreateVO.toDB();
|
SysAccount account = accountCreateVO.toDB();
|
||||||
account.setRoles(BusinessConsts.ROLE_01);
|
account.setRoles(BusinessConsts.ROLE_01);
|
||||||
account.setCreateTime(LocalDateTime.now());
|
account.setCreateTime(LocalDateTime.now());
|
||||||
|
@ -918,7 +950,7 @@ public class SysUserService implements ISysUserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountVO queryOrCreateThirdAccount(String parentAccount, String account) {
|
public AccountVO queryOrCreateThirdAccount(String parentAccount, String account, String name) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(parentAccount);
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(parentAccount);
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(account);
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(account);
|
||||||
String key = parentAccount + account;
|
String key = parentAccount + account;
|
||||||
|
@ -939,9 +971,14 @@ public class SysUserService implements ISysUserService {
|
||||||
SysAccount sysAccount = new SysAccount();
|
SysAccount sysAccount = new SysAccount();
|
||||||
sysAccount.setAccount(account);
|
sysAccount.setAccount(account);
|
||||||
sysAccount.setParentAccount(parentAccount);
|
sysAccount.setParentAccount(parentAccount);
|
||||||
sysAccount.setNickname(String.format("第三方账户%s", account));
|
if (StringUtils.hasText(name)) {
|
||||||
|
sysAccount.setName(name);
|
||||||
|
sysAccount.setNickname(name);
|
||||||
|
} else {
|
||||||
|
sysAccount.setNickname(String.format("第三方账户%s", account));
|
||||||
|
}
|
||||||
sysAccount.setType(AccountVO.Type_3);
|
sysAccount.setType(AccountVO.Type_3);
|
||||||
String initPassword = EncryptUtil.md5("123456");
|
String initPassword = EncryptUtil.md5(BusinessConsts.DEFAULT_PASSWORD);
|
||||||
sysAccount.setPassword(initPassword);
|
sysAccount.setPassword(initPassword);
|
||||||
sysAccount.setStatus(BusinessConsts.STATUS_USE);
|
sysAccount.setStatus(BusinessConsts.STATUS_USE);
|
||||||
sysAccount.setRoles(BusinessConsts.ROLE_01);
|
sysAccount.setRoles(BusinessConsts.ROLE_01);
|
||||||
|
@ -1017,10 +1054,13 @@ public class SysUserService implements ISysUserService {
|
||||||
@Override
|
@Override
|
||||||
public void register2(AccountRegisterVO registerVO) {
|
public void register2(AccountRegisterVO registerVO) {
|
||||||
if (StringUtils.hasText(registerVO.getMobile())) {
|
if (StringUtils.hasText(registerVO.getMobile())) {
|
||||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isSameMobileExist(registerVO.getMobile()));
|
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(
|
||||||
validateMobileVerificationCode(registerVO.getNationCode(), registerVO.getMobile(), registerVO.getVerificationCode());
|
isSameMobileExist(registerVO.getMobile()));
|
||||||
|
validateMobileVerificationCode(registerVO.getNationCode(), registerVO.getMobile(),
|
||||||
|
registerVO.getVerificationCode());
|
||||||
} else if (StringUtils.hasText(registerVO.getEmail())) {
|
} else if (StringUtils.hasText(registerVO.getEmail())) {
|
||||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isSameEmailExist(registerVO.getEmail()));
|
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(
|
||||||
|
isSameEmailExist(registerVO.getEmail()));
|
||||||
validateEmailVerificationCode(registerVO.getEmail(), registerVO.getVerificationCode());
|
validateEmailVerificationCode(registerVO.getEmail(), registerVO.getVerificationCode());
|
||||||
}
|
}
|
||||||
SysAccount sysAccount = registerVO.toDB();
|
SysAccount sysAccount = registerVO.toDB();
|
||||||
|
@ -1097,7 +1137,8 @@ public class SysUserService implements ISysUserService {
|
||||||
* @param account
|
* @param account
|
||||||
*/
|
*/
|
||||||
private void updateLoginUserInfoWithOrgInfo(SysAccount account) {
|
private void updateLoginUserInfoWithOrgInfo(SysAccount account) {
|
||||||
List<LoginUserInfoVO> loginUserInfoVOS = loginSessionManager.queryLoginInfoByUserId(account.getId());
|
List<LoginUserInfoVO> loginUserInfoVOS = loginSessionManager.queryLoginInfoByUserId(
|
||||||
|
account.getId());
|
||||||
if (!CollectionUtils.isEmpty(loginUserInfoVOS)) {
|
if (!CollectionUtils.isEmpty(loginUserInfoVOS)) {
|
||||||
for (LoginUserInfoVO loginInfo : loginUserInfoVOS) {
|
for (LoginUserInfoVO loginInfo : loginUserInfoVOS) {
|
||||||
AccountVO oldAccountVO = loginInfo.getAccountVO();
|
AccountVO oldAccountVO = loginInfo.getAccountVO();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package club.joylink.rtss.services.auth;
|
||||||
import club.joylink.rtss.configuration.configProp.OtherConfig;
|
import club.joylink.rtss.configuration.configProp.OtherConfig;
|
||||||
import club.joylink.rtss.configuration.configProp.WeChatConfig;
|
import club.joylink.rtss.configuration.configProp.WeChatConfig;
|
||||||
import club.joylink.rtss.constants.Client;
|
import club.joylink.rtss.constants.Client;
|
||||||
|
import club.joylink.rtss.constants.ProjectCode;
|
||||||
import club.joylink.rtss.dao.SysAccountLoginDAO;
|
import club.joylink.rtss.dao.SysAccountLoginDAO;
|
||||||
import club.joylink.rtss.entity.SysAccountLogin;
|
import club.joylink.rtss.entity.SysAccountLogin;
|
||||||
import club.joylink.rtss.entity.project.Project;
|
import club.joylink.rtss.entity.project.Project;
|
||||||
|
@ -22,6 +23,7 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.LoginStatusVO;
|
import club.joylink.rtss.vo.client.LoginStatusVO;
|
||||||
import club.joylink.rtss.vo.client.LoginUserVO;
|
import club.joylink.rtss.vo.client.LoginUserVO;
|
||||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||||
|
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
|
||||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||||
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
import club.joylink.rtss.vo.client.project.RelationLoginConfigVO;
|
import club.joylink.rtss.vo.client.project.RelationLoginConfigVO;
|
||||||
|
@ -239,6 +241,24 @@ public class AuthenticateService implements IAuthenticateService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String cgyThirdPartyLogin(CgyThirdPartyLoginInfoVO loginInfo) {
|
||||||
|
BusinessExceptionAssertEnum.INVALID_OPERATION
|
||||||
|
.assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()),
|
||||||
|
String.format("成工院父账号不存在: %s", loginInfo.getParentAccount()));
|
||||||
|
AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount(
|
||||||
|
loginInfo.getParentAccount(),
|
||||||
|
loginInfo.getAccount(),
|
||||||
|
loginInfo.getName());
|
||||||
|
ProjectVO projectVO = projectService.queryLoginProjectByCode(ProjectCode.CGY);
|
||||||
|
// 构造登陆用户信息
|
||||||
|
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(accountVO, Client.Joylink, projectVO, null);
|
||||||
|
loginUserInfo.setThirdLogin(true);
|
||||||
|
// 执行登录
|
||||||
|
login(loginUserInfo, true);
|
||||||
|
return loginUserInfo.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @update 20221019 去除设置组织信息
|
* @update 20221019 去除设置组织信息
|
||||||
*/
|
*/
|
||||||
|
@ -384,8 +404,7 @@ public class AuthenticateService implements IAuthenticateService {
|
||||||
.assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()),
|
.assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()),
|
||||||
String.format("第三方企业账号不存在: %s", loginInfo.getParentAccount()));
|
String.format("第三方企业账号不存在: %s", loginInfo.getParentAccount()));
|
||||||
AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount(
|
AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount(
|
||||||
loginInfo.getParentAccount(),
|
loginInfo.getParentAccount(), loginInfo.getAccount(), null);
|
||||||
loginInfo.getAccount());
|
|
||||||
Client client = Client.getByIdAndSecret(loginInfo.getClientId(), loginInfo.getSecret());
|
Client client = Client.getByIdAndSecret(loginInfo.getClientId(), loginInfo.getSecret());
|
||||||
ProjectVO projectVO = projectService.queryLoginProjectByCode(loginInfo.getProject());
|
ProjectVO projectVO = projectService.queryLoginProjectByCode(loginInfo.getProject());
|
||||||
// 构造登陆用户信息
|
// 构造登陆用户信息
|
||||||
|
|
|
@ -5,120 +5,127 @@ import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.LoginStatusVO;
|
import club.joylink.rtss.vo.client.LoginStatusVO;
|
||||||
import club.joylink.rtss.vo.client.LoginUserVO;
|
import club.joylink.rtss.vo.client.LoginUserVO;
|
||||||
|
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
|
||||||
|
|
||||||
public interface IAuthenticateService {
|
public interface IAuthenticateService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登陆状态/token
|
* 获取登陆状态/token
|
||||||
*
|
*
|
||||||
* @param sessionId
|
* @param sessionId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
LoginStatusVO checkStatus(String sessionId);
|
LoginStatusVO checkStatus(String sessionId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过密码登陆
|
* 通过密码登陆
|
||||||
*
|
*
|
||||||
* @param loginUser
|
* @param loginUser
|
||||||
*/
|
*/
|
||||||
String loginWithPwd(LoginUserVO loginUser);
|
String loginWithPwd(LoginUserVO loginUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方登录
|
* 第三方登录
|
||||||
*
|
*
|
||||||
* @param loginInfo
|
* @param loginInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String thirdPartyLogin(LoginUserVO loginInfo);
|
String thirdPartyLogin(LoginUserVO loginInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登出
|
* 登出
|
||||||
*
|
*
|
||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
void logout(String token);
|
void logout(String token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序扫登陆二维码
|
* 微信小程序扫登陆二维码
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @param state
|
* @param state
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AccountVO scanWmLoginQrCode(String code, String state);
|
AccountVO scanWmLoginQrCode(String code, String state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取微信小程序登陆url
|
* 获取微信小程序登陆url
|
||||||
*
|
*
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param secret
|
* @param secret
|
||||||
* @param project
|
* @param project
|
||||||
* @param deviceCode
|
* @param deviceCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// LoginStatusVO getWmLoginUrl(String clientId, String secret, Project project, String deviceCode);
|
// LoginStatusVO getWmLoginUrl(String clientId, String secret, Project project, String deviceCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 20220922 用于替换上方方法 占位
|
* TODO 20220922 用于替换上方方法 占位
|
||||||
* <p>
|
* <p>
|
||||||
* 测试文档后删除相关注释
|
* 测试文档后删除相关注释
|
||||||
*/
|
*/
|
||||||
LoginStatusVO getWmLoginUrl(String clientId, String secret, String projectCode, String deviceCode);
|
LoginStatusVO getWmLoginUrl(String clientId, String secret, String projectCode,
|
||||||
|
String deviceCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序确认登陆
|
* 微信小程序确认登陆
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
void wmConfirmClientLogin(String code, String state);
|
void wmConfirmClientLogin(String code, String state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过token获取登陆用户信息
|
* 通过token获取登陆用户信息
|
||||||
*
|
*
|
||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
LoginUserInfoVO getLoginUserInfoByToken(String token);
|
LoginUserInfoVO getLoginUserInfoByToken(String token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据微信小程序code获取用户(若不存在,创建用户);若已登录,则绑定微信
|
* 根据微信小程序code获取用户(若不存在,创建用户);若已登录,则绑定微信
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AccountVO getOrCreateUserByWmcode(WxApiService.MiniApp miniApp, String code);
|
AccountVO getOrCreateUserByWmcode(WxApiService.MiniApp miniApp, String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玖琏科技小程序code换token
|
* 玖琏科技小程序code换token
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getTokenByWmCode(String code);
|
String getTokenByWmCode(String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 到那儿了小程序code换token
|
* 到那儿了小程序code换token
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getTokenByWmCode2(String code);
|
String getTokenByWmCode2(String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 郑州共赢小程序code换token
|
* 郑州共赢小程序code换token
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getTokenByWmCode3(String code);
|
String getTokenByWmCode3(String code);
|
||||||
|
|
||||||
boolean isTokenExpired(String token);
|
boolean isTokenExpired(String token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预登出(前端在刷新/关闭标签页的时候调用)
|
* 预登出(前端在刷新/关闭标签页的时候调用)
|
||||||
*
|
*
|
||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
void preLogout(String token);
|
void preLogout(String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成工业虚仿平台跳转登录接口
|
||||||
|
*/
|
||||||
|
String cgyThirdPartyLogin(CgyThirdPartyLoginInfoVO loginInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
package club.joylink.rtss.services.cgy;
|
||||||
|
|
||||||
|
import club.joylink.rtss.bo.cgy.CgyStatsBO;
|
||||||
|
import club.joylink.rtss.dao.CgyViewDAO;
|
||||||
|
import club.joylink.rtss.entity.CgyView;
|
||||||
|
import club.joylink.rtss.entity.CgyViewExample;
|
||||||
|
import club.joylink.rtss.entity.UserSimulationRecord;
|
||||||
|
import club.joylink.rtss.event.UserSimulationRecordEvent;
|
||||||
|
import club.joylink.rtss.services.user.UserSimulationRecordService;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.SimulationService;
|
||||||
|
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
||||||
|
import club.joylink.rtss.util.EncryptUtil;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.simulationUsage.SimulationUsageRecordQueryVO;
|
||||||
|
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成工院虚仿平台对接统计服务
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CgyStatsService {
|
||||||
|
|
||||||
|
private CgyViewDAO cgyViewDAO;
|
||||||
|
private UserSimulationRecordService userSimulationRecordService;
|
||||||
|
private SimulationService simulationService;
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CgyStatsService(CgyViewDAO cgyViewDAO,
|
||||||
|
UserSimulationRecordService userSimulationRecordService,
|
||||||
|
SimulationService simulationService, RestTemplate restTemplate) {
|
||||||
|
this.cgyViewDAO = cgyViewDAO;
|
||||||
|
this.userSimulationRecordService = userSimulationRecordService;
|
||||||
|
this.simulationService = simulationService;
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<String, CgyStatsBO> appStatsMap = new ConcurrentHashMap<>();
|
||||||
|
private final ConcurrentHashMap<Long, CgyStatsBO> functionStatsMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void makeCache() {
|
||||||
|
List<CgyView> cgyViews = cgyViewDAO.selectByExample(new CgyViewExample());
|
||||||
|
if (CollectionUtils.isEmpty(cgyViews)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cgyViews.forEach(cgyView -> {
|
||||||
|
CgyStatsBO bo = new CgyStatsBO(cgyView.getAppId(), cgyView.getAppSecret(),
|
||||||
|
cgyView.getFunctionId());
|
||||||
|
bo.setView(new AtomicLong(cgyView.getViewCount()));
|
||||||
|
makeCache(bo);
|
||||||
|
appStatsMap.put(cgyView.getAppId(), bo);
|
||||||
|
functionStatsMap.put(cgyView.getFunctionId(), bo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向虚仿平台同步数据
|
||||||
|
*/
|
||||||
|
@Scheduled(fixedRate = 2000)
|
||||||
|
public void syncData() {
|
||||||
|
appStatsMap.forEach((appId, statsBO) -> {
|
||||||
|
if (!statsBO.getChange().getAndSet(false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//同步汇总数据
|
||||||
|
Map<String, Object> body = new HashMap<>();
|
||||||
|
body.put("appId", appId);
|
||||||
|
body.put("timestamp", System.currentTimeMillis());
|
||||||
|
body.put("view", statsBO.getView().get());
|
||||||
|
body.put("visitor", statsBO.getVisitor().get());
|
||||||
|
body.put("user", statsBO.getUserSet().size());
|
||||||
|
//扩展字段
|
||||||
|
body.put("duration", statsBO.getDuration().get());
|
||||||
|
SimulationInfoQueryVO queryVO = new SimulationInfoQueryVO();
|
||||||
|
queryVO.setFunctionId(statsBO.getFunctionId());
|
||||||
|
List<SimulationInfoVO> sims = simulationService.listAllSimulation(queryVO);
|
||||||
|
body.put("onlineUser", sims.size());
|
||||||
|
|
||||||
|
String sb = "appId="
|
||||||
|
+ body.get("appId") + "&"
|
||||||
|
+ "timestamp="
|
||||||
|
+ body.get("timestamp") + "&"
|
||||||
|
+ "user="
|
||||||
|
+ body.get("user") + "&"
|
||||||
|
+ "view="
|
||||||
|
+ body.get("view") + "&"
|
||||||
|
+ "visitor="
|
||||||
|
+ body.get("visitor") + "&"
|
||||||
|
+ "app_secret="
|
||||||
|
+ statsBO.getAppSecret();
|
||||||
|
body.put("sign", EncryptUtil.md5(sb).toLowerCase());
|
||||||
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
HttpEntity<String> httpEntity = new HttpEntity<>(JsonUtils.writeValueAsString(body),
|
||||||
|
httpHeaders);
|
||||||
|
|
||||||
|
Map<String, String> resBody = restTemplate.postForObject(
|
||||||
|
"/api/applicationCenter/openapi/summary", httpEntity, Map.class);
|
||||||
|
if (resBody != null && Objects.equals(resBody.get("code"), "100001")) {
|
||||||
|
log.error(String.format("成工院虚仿平台同步数据失败:[%s][%s]", resBody.get("msg"),
|
||||||
|
resBody.get("data")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async("thirdAccountDataSyncExecutor")
|
||||||
|
@EventListener
|
||||||
|
public void syncUserSimulationUsing(UserSimulationRecordEvent event) {
|
||||||
|
UserSimulationRecord record = event.getRecord();
|
||||||
|
CgyStatsBO cgyStatsBO = functionStatsMap.get(record.getFunctionId());
|
||||||
|
cgyStatsBO.getVisitor().incrementAndGet();
|
||||||
|
cgyStatsBO.getUserSet().add(record.getUserId());
|
||||||
|
cgyStatsBO.getDuration().addAndGet(record.getDuration());
|
||||||
|
cgyStatsBO.getChange().set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新此App的浏览量数据
|
||||||
|
*/
|
||||||
|
public void updateView(String appId) {
|
||||||
|
CgyStatsBO cgyStatsBO = appStatsMap.get(appId);
|
||||||
|
if (cgyStatsBO == null) {
|
||||||
|
log.warn(String.format("成工院虚仿平台未知的appId:%s", appId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long count = cgyStatsBO.getView().incrementAndGet();
|
||||||
|
CgyView record = new CgyView();
|
||||||
|
record.setAppId(appId);
|
||||||
|
record.setViewCount(count);
|
||||||
|
CgyViewExample example = new CgyViewExample();
|
||||||
|
example.createCriteria().andAppIdEqualTo(appId).andViewCountLessThan(count);
|
||||||
|
cgyViewDAO.updateByExampleSelective(record, example);
|
||||||
|
cgyStatsBO.getChange().set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实训人数、实训人次、实训时长缓存
|
||||||
|
*/
|
||||||
|
private void makeCache(CgyStatsBO bo) {
|
||||||
|
long visitor = 0;
|
||||||
|
long duration = 0;
|
||||||
|
//实训人数、人次、时长
|
||||||
|
List<UserSimulationRecord> records = userSimulationRecordService.listSimulationUsageRecords(
|
||||||
|
new SimulationUsageRecordQueryVO(null, bo.getFunctionId()));
|
||||||
|
if (!CollectionUtils.isEmpty(records)) {
|
||||||
|
visitor = records.size();
|
||||||
|
for (UserSimulationRecord record : records) {
|
||||||
|
bo.getUserSet().add(record.getUserId()); //实训人数
|
||||||
|
duration += record.getDuration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bo.setVisitor(new AtomicLong(visitor)); //实训人次
|
||||||
|
bo.setDuration(new AtomicLong(duration)); //实训时长
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import club.joylink.rtss.entity.RtsMapFunction;
|
||||||
import club.joylink.rtss.entity.SysAccount;
|
import club.joylink.rtss.entity.SysAccount;
|
||||||
import club.joylink.rtss.entity.UserSimulationRecord;
|
import club.joylink.rtss.entity.UserSimulationRecord;
|
||||||
import club.joylink.rtss.entity.UserSimulationRecordExample;
|
import club.joylink.rtss.entity.UserSimulationRecordExample;
|
||||||
|
import club.joylink.rtss.entity.UserSimulationRecordExample.Criteria;
|
||||||
import club.joylink.rtss.event.UserSimulationRecordEvent;
|
import club.joylink.rtss.event.UserSimulationRecordEvent;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.services.IMapService;
|
import club.joylink.rtss.services.IMapService;
|
||||||
|
@ -13,6 +14,7 @@ import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
|
||||||
import club.joylink.rtss.simulation.cbtc.message.UserSimulationRecordManager;
|
import club.joylink.rtss.simulation.cbtc.message.UserSimulationRecordManager;
|
||||||
import club.joylink.rtss.util.TimeUnit;
|
import club.joylink.rtss.util.TimeUnit;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
|
import club.joylink.rtss.vo.client.simulationUsage.SimulationUsageRecordQueryVO;
|
||||||
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationQueryVO;
|
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationQueryVO;
|
||||||
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationRecordVO;
|
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationRecordVO;
|
||||||
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsVO;
|
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsVO;
|
||||||
|
@ -66,7 +68,8 @@ public class UserSimulationRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserSimulationRecord> queryByMapAndUserIds(Long mapId, List<Long> userIds) {
|
public List<UserSimulationRecord> queryByMapAndUserIds(Long mapId, List<Long> userIds) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds, "用户列表不能为空");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds,
|
||||||
|
"用户列表不能为空");
|
||||||
UserSimulationRecordExample example = new UserSimulationRecordExample();
|
UserSimulationRecordExample example = new UserSimulationRecordExample();
|
||||||
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIn(userIds);
|
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIn(userIds);
|
||||||
return userSimulationRecordDAO.selectByExample(example);
|
return userSimulationRecordDAO.selectByExample(example);
|
||||||
|
@ -165,6 +168,22 @@ public class UserSimulationRecordService {
|
||||||
return statistic(startTime, endTime, timeUnit, list);
|
return statistic(startTime, endTime, timeUnit, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询仿真使用记录
|
||||||
|
*/
|
||||||
|
public List<UserSimulationRecord> listSimulationUsageRecords(
|
||||||
|
SimulationUsageRecordQueryVO queryVO) {
|
||||||
|
UserSimulationRecordExample example = new UserSimulationRecordExample();
|
||||||
|
Criteria criteria = example.createCriteria();
|
||||||
|
if (queryVO.getUid() != null) {
|
||||||
|
criteria.andUserIdEqualTo(queryVO.getUid());
|
||||||
|
}
|
||||||
|
if (queryVO.getFunctionId() != null) {
|
||||||
|
criteria.andFunctionIdEqualTo(queryVO.getFunctionId());
|
||||||
|
}
|
||||||
|
return userSimulationRecordDAO.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对使用记录按照时间单位、开始、结束时间分段统计
|
* 对使用记录按照时间单位、开始、结束时间分段统计
|
||||||
*/
|
*/
|
||||||
|
@ -223,9 +242,12 @@ public class UserSimulationRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkParam(UserSimulationQueryVO queryVO) {
|
private void checkParam(UserSimulationQueryVO queryVO) {
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getTimeUnit(), "缺少时间单位");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getTimeUnit(),
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getStartTime(), "缺少开始时间");
|
"缺少时间单位");
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getEndTime(), "缺少结束时间");
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getStartTime(),
|
||||||
|
"缺少开始时间");
|
||||||
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getEndTime(),
|
||||||
|
"缺少结束时间");
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||||
!queryVO.getStartTime().isAfter(queryVO.getEndTime()), "开始时间不能晚于结束时间");
|
!queryVO.getStartTime().isAfter(queryVO.getEndTime()), "开始时间不能晚于结束时间");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
package club.joylink.rtss.services.voice.huawei;
|
|
||||||
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
|
||||||
import club.joylink.rtss.services.voice.IVoiceService;
|
|
||||||
import club.joylink.rtss.util.VoiceFileUtils;
|
|
||||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
|
||||||
import com.huawei.sis.bean.AuthInfo;
|
|
||||||
import com.huawei.sis.bean.SisConfig;
|
|
||||||
import com.huawei.sis.bean.request.AsrCustomShortRequest;
|
|
||||||
import com.huawei.sis.bean.response.AsrCustomShortResponse;
|
|
||||||
import com.huawei.sis.client.AsrCustomizationClient;
|
|
||||||
import com.huawei.sis.exception.SisException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service("HuaWeiVoiceService")
|
|
||||||
public class HuaweiVoiceServiceImpl implements IVoiceService {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String synthesis(String message, String per) {
|
|
||||||
throw BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.exception("功能暂未实现");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String synthesis(String message) {
|
|
||||||
return this.synthesis(message, "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 华为语音识别配置
|
|
||||||
*//*
|
|
||||||
|
|
||||||
private final String ak = "YDUXTXRYGAHGPHAIXZCU";
|
|
||||||
private final String sk = "Kcbm3sTDCYEou8kGeAhKxfBkgWybIn6IjJyGBX3p";
|
|
||||||
private final String region = "cn-north-4";
|
|
||||||
private final String projectId = "0aada8176180f28c2f34c0196f5394e8";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoiceRecognitionResult voiceRecognition(MultipartFile file, String lang) {
|
|
||||||
String filePath = VoiceFileUtils.saveFile(file);
|
|
||||||
try {
|
|
||||||
return voiceRecognition(file.getBytes(), filePath);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("第三方服务调用异常");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath) {
|
|
||||||
AuthInfo authInfo = new AuthInfo(ak, sk, region, projectId);
|
|
||||||
SisConfig sisConfig = new SisConfig();
|
|
||||||
AsrCustomizationClient client = new AsrCustomizationClient(authInfo, sisConfig);
|
|
||||||
String data = Base64.getEncoder().encodeToString(bytes);
|
|
||||||
try {
|
|
||||||
AsrCustomShortRequest request = new AsrCustomShortRequest(data, "pcm16k16bit", "chinese_16k_common");
|
|
||||||
AsrCustomShortResponse response = client.getAsrShortResponse(request);
|
|
||||||
return new VoiceRecognitionResult(filePath, response.getResult().getText());
|
|
||||||
} catch (SisException e) {
|
|
||||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音识别失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public VoiceRecognitionResult voiceRecognition(String fileBase64) {
|
|
||||||
String base64 = fileBase64.substring(fileBase64.indexOf("base64,") + "base64,".length());
|
|
||||||
byte[] bytes = Base64.getDecoder().decode(base64.trim());
|
|
||||||
String filePath = VoiceFileUtils.saveFile(bytes);
|
|
||||||
return voiceRecognition(bytes, filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,154 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.operation.SimulationOperationDispatcher;
|
|
||||||
//import club.joylink.rtss.simulation.vo.SimulationFaultVO;
|
|
||||||
//import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
|
||||||
//import club.joylink.rtss.simulation.vo.SimulationMemberVO;
|
|
||||||
//import club.joylink.rtss.simulation.vo.SimulationUserVO;
|
|
||||||
//import club.joylink.rtss.vo.LoginUserInfoVO;
|
|
||||||
//import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.util.StringUtils;
|
|
||||||
//import org.springframework.web.bind.annotation.*;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Map;
|
|
||||||
//import java.util.Objects;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//import java.util.stream.Stream;
|
|
||||||
//
|
|
||||||
//import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 仿真通用接口
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@RestController
|
|
||||||
//@RequestMapping("/common/simulation")
|
|
||||||
//public class SimulationCommonController {
|
|
||||||
// @Autowired
|
|
||||||
// private SimulationManager simulationManager;
|
|
||||||
// @Autowired
|
|
||||||
// private SimulationOperationDispatcher simulationOperationDispatcher;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 监管仿真
|
|
||||||
// * @param loginUserInfoVO
|
|
||||||
// * @param queryVO
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// @GetMapping("/supervise")
|
|
||||||
// public List<SimulationInfoVO> superviseSimulation(@RequestAttribute(name=LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, SimulationInfoQueryVO queryVO) {
|
|
||||||
// List<Simulation> simulationList = this.simulationManager.getSimulationList();
|
|
||||||
// Stream<Simulation> stream = simulationList.stream();
|
|
||||||
//
|
|
||||||
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
|
|
||||||
// && Objects.equals(loginUserInfoVO.getTopOrgId(),((club.joylink.rtss.simulation.cbtc.Simulation)simulation).getBuildParams().getLoginUserInfo().getTopOrgId()));
|
|
||||||
//
|
|
||||||
// if (StringUtils.hasText(queryVO.getGroup())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
|
||||||
// }
|
|
||||||
// if (StringUtils.hasText(queryVO.getUserName())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> ((SimulationUser) user).getName().contains(queryVO.getUserName())));
|
|
||||||
// }
|
|
||||||
// if (StringUtils.hasText(queryVO.getPrdType())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
|
|
||||||
// && queryVO.getPrdType().equals(((club.joylink.rtss.simulation.cbtc.Simulation) simulation).getBuildParams().getProdType().getCode()));
|
|
||||||
// }
|
|
||||||
// return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/list")
|
|
||||||
// public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
|
|
||||||
// List<Simulation> simulationList = this.simulationManager.getSimulationList();
|
|
||||||
// Stream<Simulation> stream = simulationList.stream();
|
|
||||||
// if (StringUtils.hasText(queryVO.getGroup())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
|
||||||
// }
|
|
||||||
// if (StringUtils.hasText(queryVO.getUserName())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> ((SimulationUser) user).getName().contains(queryVO.getUserName())));
|
|
||||||
// }
|
|
||||||
// if (StringUtils.hasText(queryVO.getPrdType())) {
|
|
||||||
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
|
|
||||||
// && queryVO.getPrdType().equals(((club.joylink.rtss.simulation.cbtc.Simulation) simulation).getBuildParams().getProdType().getCode()));
|
|
||||||
// }
|
|
||||||
// return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PutMapping("/{id}/pause")
|
|
||||||
// public void pause(@PathVariable String id) {
|
|
||||||
// this.simulationManager.pause(id);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PutMapping("/{id}/start")
|
|
||||||
// public void start(@PathVariable String id) {
|
|
||||||
// this.simulationManager.start(id);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PutMapping("/{id}/init")
|
|
||||||
// public void init(@PathVariable String id) {
|
|
||||||
// this.simulationManager.init(id);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PutMapping("/{id}/updateSpeed/{speed}")
|
|
||||||
// public void updateSpeed(@PathVariable String id, @PathVariable int speed) {
|
|
||||||
// this.simulationManager.updateSpeed(id, speed);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/{id}")
|
|
||||||
// public SimulationInfoVO getSimulationInfo(@PathVariable String id) {
|
|
||||||
// return this.simulationManager.getById(id).convertToVO();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/{id}/users")
|
|
||||||
// public List<SimulationUserVO> getSimulationUsers(@PathVariable String id) {
|
|
||||||
// return this.simulationManager.getSimulationUsers(id).stream()
|
|
||||||
// .map(SimulationUser::convertToVO)
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/{id}/members")
|
|
||||||
// public List<SimulationMemberVO> getSimulationMembers(@PathVariable String id, @RequestParam(required = false) String role) {
|
|
||||||
// return this.simulationManager.getSimulationMembers(id).stream()
|
|
||||||
// .map(SimulationMember::convertToVO)
|
|
||||||
// .filter(member -> StringUtils.hasText(role) ? member.getRole().toString().equals(role) : true)
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @GetMapping("/{id}/member/playedBy/{userId}")
|
|
||||||
// public SimulationMemberVO queryUserPlayedMember(@PathVariable String id, @PathVariable String userId) {
|
|
||||||
// return this.simulationManager.getById(id)
|
|
||||||
// .getSimulationMemberByUserId(userId).convertToVO();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PostMapping("/{id}/member/{memberId}/operate/{type}")
|
|
||||||
// public Object operate(@PathVariable String id, @PathVariable String memberId,
|
|
||||||
// @PathVariable String type, @RequestBody Map<String, Object> params) {
|
|
||||||
// return this.simulationOperationDispatcher.doDispatch(id, memberId, type, params);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 故障注入
|
|
||||||
// */
|
|
||||||
// @PostMapping("/{id}/fault")
|
|
||||||
// public void injectFault(@PathVariable String id, @RequestBody SimulationFaultVO faultVO) {
|
|
||||||
// this.simulationManager.injectFault(id, faultVO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @DeleteMapping("/{id}/device/{deviceId}/fault/{fault}")
|
|
||||||
// public void removeFault(@PathVariable String id, @PathVariable String deviceId, @PathVariable String fault) {
|
|
||||||
// this.simulationManager.removeFault(id, deviceId, fault);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @PutMapping("/{id}/member/{memberId}/playby/{userId}")
|
|
||||||
// public void memberPlay(@PathVariable String id, @PathVariable String memberId, @PathVariable String userId) {
|
|
||||||
// this.simulationManager.memberPlayedByUser(id, memberId, userId);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @DeleteMapping("/{id}/destroy")
|
|
||||||
// public void destroy(@PathVariable String id) {
|
|
||||||
// this.simulationManager.destroy(id);
|
|
||||||
// log.info(String.format("仿真通用接口销毁仿真[%s]", id));
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,687 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.ATP.ground;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.CI.service.RouteService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.util.*;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * ZC逻辑循环
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class ZCLogicLoop {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private OnboardAtpApiService onboardAtpApiService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private ATPService ATPService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private AtsApiService atsApiService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private MaService maService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// public void run(Simulation simulation) {
|
|
||||||
// List<VirtualRealityTrain> trainList = simulation.getRepository().getOnlineTrainList();
|
|
||||||
// trainList.forEach(train -> {
|
|
||||||
// SectionPosition headPosition = train.getHeadPosition();
|
|
||||||
// Station deviceStation = headPosition.getSection().getDeviceStation();
|
|
||||||
// RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode();
|
|
||||||
// if (RunLevel.ITC.equals(defaultRunLevel)) { //如果线路最高运行级别为ITC级别
|
|
||||||
// if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// this.calculateMAOfITC(simulation, train);
|
|
||||||
// }
|
|
||||||
// } else if (RunLevel.CBTC.equals(defaultRunLevel)) {
|
|
||||||
// //更新ITC ma
|
|
||||||
// if (!simulation.getRepository().hasResponder()) {
|
|
||||||
// if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// Float distance2NextSignal = train.calculateDistance2NextNormalOpenSignal();
|
|
||||||
// if (distance2NextSignal != null && distance2NextSignal <= 5) {
|
|
||||||
// train.setPositioned(true);
|
|
||||||
// this.calculateMAOfITC(simulation, train);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// simulation.getRepository().getSectionRespondersMap().forEach((section, responders) ->
|
|
||||||
// responders.stream()
|
|
||||||
// .filter(Responder::isVB)
|
|
||||||
// .forEach(responder -> {
|
|
||||||
// if (responder.getSignal().isNormalOpen()) {
|
|
||||||
// responder.setMa(this.calculateMAOfITC(simulation, responder));
|
|
||||||
// }
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
// //更新CBTC ma
|
|
||||||
// if (train.isCommunicable()) {
|
|
||||||
// this.calculateMAOfCBTC(simulation, train, trainList);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train,
|
|
||||||
// List<VirtualRealityTrain> trainList) {
|
|
||||||
// // 查找移动授权终端列表
|
|
||||||
// List<MovementAuthority.End> endList = this.findMaEnd(simulation, train, trainList);
|
|
||||||
// // 根据查找到的授权终端,比较并构建最终的移动授权数据
|
|
||||||
// MovementAuthority ma = this.compareAndBuildMa(train, endList);
|
|
||||||
// // 通知车载ATP
|
|
||||||
// this.onboardAtpApiService.updateMA4CBTC(train, ma);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 计算移动授权终端
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param train
|
|
||||||
// * @param trainList
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// private List<MovementAuthority.End> findMaEnd(Simulation simulation, VirtualRealityTrain train, List<VirtualRealityTrain> trainList) {
|
|
||||||
// // 从车尾开始找(车尾主要查看是否在站台轨上,且站台轨屏蔽门开放)
|
|
||||||
// boolean right = train.isRight();
|
|
||||||
// SectionPosition headPosition = train.getHeadPosition();
|
|
||||||
// SectionPosition tailPosition = train.calculateTailPosition();
|
|
||||||
// Section tailSection = tailPosition.getSection();
|
|
||||||
// MovementAuthority.End openPsdEnd = checkPsdOpenOrClose(tailSection);
|
|
||||||
// List<MovementAuthority.End> endList = new ArrayList<>();
|
|
||||||
// if (openPsdEnd != null)
|
|
||||||
// endList.add(openPsdEnd);
|
|
||||||
// MovementAuthority.End ecStandEnd = checkEC(simulation.getRepository().getConfig(), tailSection);
|
|
||||||
// if (ecStandEnd != null)
|
|
||||||
// endList.add(ecStandEnd);
|
|
||||||
// MovementAuthority.End closedSection = checkClosedSection(tailSection);
|
|
||||||
// if (closedSection != null)
|
|
||||||
// return List.of(closedSection);
|
|
||||||
// // 如果车尾正常,从车头开始往前查找
|
|
||||||
// Section section = headPosition.getSection();
|
|
||||||
// MovementAuthority.End switchEnd = checkSwitch(tailSection, section, right);
|
|
||||||
// if (switchEnd != null)
|
|
||||||
// return List.of(switchEnd);
|
|
||||||
// // 检查列车当前所在进路是否锁闭
|
|
||||||
//// MovementAuthority.End end1 = this.checkRouteLock(simulation, section, tailSection, right, train);
|
|
||||||
//// if (Objects.nonNull(end1)) {
|
|
||||||
//// endList.add(end1);
|
|
||||||
//// return endList;
|
|
||||||
//// }
|
|
||||||
//// // 检查车头区段是否故障
|
|
||||||
//// if (headPosition.getSection().isFault()) {
|
|
||||||
//// endList.add(new MovementAuthority.End(headPosition.getSection(), MovementAuthority.EndType.FAULT_SECTION));
|
|
||||||
//// }
|
|
||||||
// //非通信车占用区段
|
|
||||||
// if (section.hasNctOccupy() && !section.isInvalid()) {
|
|
||||||
// endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION));
|
|
||||||
// return endList;
|
|
||||||
// }
|
|
||||||
// //通信车占用区段
|
|
||||||
// List<Section> occupiedLogicSectionList = simulation.getRepository().queryTrainOccupyAtpSectionList(train.getGroupNumber());
|
|
||||||
// Set<Section> occupiedLogicSectionSet;
|
|
||||||
// if (!CollectionUtils.isEmpty(occupiedLogicSectionList)) {
|
|
||||||
// occupiedLogicSectionSet = new HashSet<>(occupiedLogicSectionList);
|
|
||||||
// } else {
|
|
||||||
// occupiedLogicSectionSet = new HashSet<>();
|
|
||||||
// }
|
|
||||||
// List<Section> logicList = section.getLogicList();
|
|
||||||
// if (!CollectionUtils.isEmpty(logicList)) {
|
|
||||||
// Section logicSection = headPosition.getLogicSection();
|
|
||||||
// int index = logicList.indexOf(logicSection);
|
|
||||||
// if (right) {
|
|
||||||
// for (int i = index + 1; i < logicList.size(); i++) {
|
|
||||||
// MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet);
|
|
||||||
// if (end != null)
|
|
||||||
// endList.add(end);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// for (int i = index - 1; i >= 0; i--) {
|
|
||||||
// MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet);
|
|
||||||
// if (end != null)
|
|
||||||
// endList.add(end);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// int count = 0;
|
|
||||||
// while (count < 50) {
|
|
||||||
// ++count;
|
|
||||||
//// // 区段未进路锁闭或延时解锁中(转换轨除外,因为出库列车加载到转换轨没有进路)
|
|
||||||
//// if (!section.isTransferTrack()) {
|
|
||||||
//// if (section.isDelayUnlock()) {
|
|
||||||
//// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION);
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// if (!section.isRouteLock()) {
|
|
||||||
//// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION);
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// // 站台屏蔽门
|
|
||||||
// MovementAuthority.End psdEnd = checkPsdOpenOrClose(section);
|
|
||||||
// if (psdEnd != null)
|
|
||||||
// endList.add(psdEnd);
|
|
||||||
// // 紧急关闭的站台
|
|
||||||
// MovementAuthority.End standEnd = checkEC(simulation.getRepository().getConfig(), section);
|
|
||||||
// if (standEnd != null)
|
|
||||||
// endList.add(standEnd);
|
|
||||||
// // 信号机
|
|
||||||
// MovementAuthority.End signalEnd = checkSignal(section, right);
|
|
||||||
// if (Objects.nonNull(signalEnd)) {
|
|
||||||
// endList.add(signalEnd);
|
|
||||||
// MovementAuthority.End unlockedOverlapEnd = this.checkUnlockedOverlap(simulation, section, right);
|
|
||||||
// if (Objects.nonNull(unlockedOverlapEnd)) {
|
|
||||||
// endList.add(unlockedOverlapEnd);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 道岔
|
|
||||||
// MovementAuthority.End end = checkSwitch(section, right);
|
|
||||||
// if (end != null)
|
|
||||||
// endList.add(end);
|
|
||||||
// // 轨道尽头/问题道岔
|
|
||||||
// Section temp = section.getNextRunningSectionOf(right);
|
|
||||||
// if (Objects.isNull(temp)) { // 到尽头
|
|
||||||
// if (!section.isSwitchTrack()) { // 问题道岔
|
|
||||||
// endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.END_TRACK));
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// //通信车占用区段
|
|
||||||
// MovementAuthority.End trainEnd = checkSectionOccupied(temp, right, occupiedLogicSectionSet);
|
|
||||||
// if (trainEnd != null)
|
|
||||||
// endList.add(trainEnd);
|
|
||||||
// //非通信车占用区段
|
|
||||||
// if (temp.hasNctOccupy() && !temp.isInvalid()) {
|
|
||||||
// endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_SECTION));
|
|
||||||
// }
|
|
||||||
// //检查关闭的区段
|
|
||||||
// MovementAuthority.End cs = checkClosedSection(section);
|
|
||||||
// if (cs != null)
|
|
||||||
// endList.add(cs);
|
|
||||||
//
|
|
||||||
// if (endList.stream().anyMatch(end2 -> !MovementAuthority.EndType.CLOSED_SIGNAL.equals(end2.getType()))) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// section = temp;
|
|
||||||
// }
|
|
||||||
//// // 前方列车
|
|
||||||
//// VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList);
|
|
||||||
//// if (Objects.nonNull(frontTrain)) {
|
|
||||||
//// Section baseSection;
|
|
||||||
//// if (Objects.equals(frontTrain.isRight(), train.isRight())) {
|
|
||||||
//// baseSection = frontTrain.calculateTailPosition().getSection();
|
|
||||||
//// } else {
|
|
||||||
//// baseSection = frontTrain.getHeadPosition().getSection();
|
|
||||||
//// }
|
|
||||||
//// endList.add(new MovementAuthority.End(frontTrain,
|
|
||||||
//// MovementAuthority.EndType.FRONT_TRAIN,
|
|
||||||
//// baseSection));
|
|
||||||
//// }
|
|
||||||
// return endList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkSectionOccupied(Section section, boolean right, Set<Section> occupiedLogicSectionSet) {
|
|
||||||
// List<Section> logicList = section.getLogicList();
|
|
||||||
// if (!CollectionUtils.isEmpty(logicList)) {
|
|
||||||
// if (right) {
|
|
||||||
// for (Section logic : logicList) {
|
|
||||||
// if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) {
|
|
||||||
// return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// for (int i = logicList.size() - 1; i >= 0; i--) {
|
|
||||||
// Section logic = logicList.get(i);
|
|
||||||
// if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) {
|
|
||||||
// return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (section.isCtOccupied() && !occupiedLogicSectionSet.contains(section)) {
|
|
||||||
// return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) {
|
|
||||||
// Section section = tailSection;
|
|
||||||
// for (int i = 0; i < 10; i++) {
|
|
||||||
// if (section == null || section.equals(headSection))
|
|
||||||
// break;
|
|
||||||
// MovementAuthority.End end = checkSwitch(section, right);
|
|
||||||
// if (end != null)
|
|
||||||
// return end;
|
|
||||||
// section = section.getNextRunningSectionOf(right);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkSwitch(Section section, boolean right) {
|
|
||||||
// Switch relSwitch = section.getRelSwitch();
|
|
||||||
// Section nextSection = section.getNextRunningSectionOf(right);
|
|
||||||
// if (relSwitch != null) { //是道岔区段
|
|
||||||
// Route route = relSwitch.getRoute();
|
|
||||||
// Section previousSection = section.getNextRunningSectionOf(!right);
|
|
||||||
// if (previousSection == null)
|
|
||||||
// return null;
|
|
||||||
// if (route != null) { //道岔进路锁闭
|
|
||||||
// if (relSwitch.isLoss()) { //失表且下个区段
|
|
||||||
// return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection);
|
|
||||||
// } else {
|
|
||||||
// List<RouteFls> flsList = route.getFlsList();
|
|
||||||
// if (!CollectionUtils.isEmpty(flsList)) {
|
|
||||||
// List<RouteFls> fls = flsList.stream()
|
|
||||||
// .filter(routeFls -> routeFls.getBase().getASwitch().equals(relSwitch))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// if (!routeService.isFlsCheckPass(fls)) {
|
|
||||||
// return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkClosedSection(Section section) {
|
|
||||||
// if (section.isClosed()) {
|
|
||||||
// return new MovementAuthority.End(section, MovementAuthority.EndType.CLOSED_SECTION);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkEC(MapConfig config, Section section) {
|
|
||||||
// if (section.isNormalStandTrack()) {
|
|
||||||
// Station station = section.getStation();
|
|
||||||
// if (config.isSharingECStation(station.getCode())) {
|
|
||||||
// for (Stand stand : station.getAllStandList()) {
|
|
||||||
// if (stand.isEmergencyClosed()) {
|
|
||||||
// return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// List<Stand> standList = section.getStandList();
|
|
||||||
// for (Stand stand : standList) {
|
|
||||||
// if (stand.isEmergencyClosed()) {
|
|
||||||
// return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkUnlockedOverlap(Simulation simulation, Section section, boolean right) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// // 判断是否已经办理进路的区段
|
|
||||||
// Route route = null;
|
|
||||||
// if (section.isRouteLock()) {
|
|
||||||
// List<Route> settingRoutes = repository.getSettingRoutes();
|
|
||||||
// for (Route settingRoute : settingRoutes) {
|
|
||||||
// if (settingRoute.isLastRouteSection(section)) {
|
|
||||||
// route = settingRoute;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (Objects.nonNull(route) && repository.isOverlapNeedSetting(route)) { // 进路需要办理延续保护
|
|
||||||
// RouteOverlap overlap = route.getOverlap();
|
|
||||||
// if (!overlap.isLock()) { // 延续保护未锁闭
|
|
||||||
// return new MovementAuthority.End(overlap,
|
|
||||||
// MovementAuthority.EndType.UNLOCKED_OVERLAP, overlap.getSection());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void calculateMAOfITC(Simulation simulation, VirtualRealityTrain train) {
|
|
||||||
// // 查找移动授权终端列表
|
|
||||||
// List<MovementAuthority.End> endList = this.findItcMaEnd(train.getHeadPosition(), train.isRight());
|
|
||||||
// if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// // 根据查找到的授权终端,比较并构建最终的移动授权数据
|
|
||||||
// MovementAuthority ma = this.compareAndBuildMa(train, endList);
|
|
||||||
// // 通知车载ATP
|
|
||||||
// this.onboardAtpApiService.updateMA4ITC(train, ma);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public MovementAuthority calculateMAOfITC(Simulation simulation, Responder responder) {
|
|
||||||
// // 查找移动授权终端列表
|
|
||||||
// List<MovementAuthority.End> endList = this.findItcMaEnd(responder.getPosition(), responder.getSignal().isRight());
|
|
||||||
// if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// // 根据查找到的授权终端,比较并构建最终的移动授权数据
|
|
||||||
// MovementAuthority ma = this.compareAndBuildMa(responder.getSignal().isRight(), endList);
|
|
||||||
// // 通知车载ATP
|
|
||||||
// return ma;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private List<MovementAuthority.End> findItcMaEnd(SectionPosition position, boolean right) {
|
|
||||||
// List<MovementAuthority.End> endList = new ArrayList<>();
|
|
||||||
// MovementAuthority.End deviceEnd = null;
|
|
||||||
// Section section = position.getSection();
|
|
||||||
// int count = 0;
|
|
||||||
// while (Objects.nonNull(section) && count < 20) {
|
|
||||||
// if (count > 1 && !CollectionUtils.isEmpty(endList))
|
|
||||||
// break;
|
|
||||||
// ++count;
|
|
||||||
// // 信号机
|
|
||||||
// MovementAuthority.End signalEnd = checkGroundSignal(section, right);
|
|
||||||
// if (Objects.nonNull(signalEnd)) {
|
|
||||||
// endList.add(signalEnd);
|
|
||||||
//// deviceEnd = signalEnd;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// // 轨道尽头/问题道岔
|
|
||||||
// Section temp = section.getNextRunningSectionOf(right);
|
|
||||||
// if (Objects.isNull(temp)) { // 到尽头
|
|
||||||
// if (!section.isSwitchTrack()) { // 问题道岔
|
|
||||||
// endList.add(new MovementAuthority.End(section,
|
|
||||||
// MovementAuthority.EndType.END_TRACK));
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (Objects.nonNull(deviceEnd)) {
|
|
||||||
// endList.add(deviceEnd);
|
|
||||||
// }
|
|
||||||
// return endList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 比较并构建移动授权数据
|
|
||||||
// *
|
|
||||||
// * @param train
|
|
||||||
// * @param endList
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// private MovementAuthority compareAndBuildMa(VirtualRealityTrain train, List<MovementAuthority.End> endList) {
|
|
||||||
// return compareAndBuildMa(train.isRight(), endList);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 比较并构建移动授权数据
|
|
||||||
// *
|
|
||||||
// * @param endList
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// private MovementAuthority compareAndBuildMa(boolean right, List<MovementAuthority.End> endList) {
|
|
||||||
// MovementAuthority.End end = null;
|
|
||||||
// if (endList.size() == 1) { // 只有一个,直接构建移动授权
|
|
||||||
// end = endList.get(0);
|
|
||||||
// } else {
|
|
||||||
// for (MovementAuthority.End temp : endList) {
|
|
||||||
// if (Objects.isNull(end)) {
|
|
||||||
// end = temp;
|
|
||||||
// } else {
|
|
||||||
// if (end.isAheadOf(temp, right)) {
|
|
||||||
// end = temp;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(end);
|
|
||||||
// end.confirmEndPosition(right);
|
|
||||||
// return new MovementAuthority(end);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private VirtualRealityTrain queryFrontTrain(VirtualRealityTrain train, List<VirtualRealityTrain> trainList) {
|
|
||||||
// boolean right = train.isRight();
|
|
||||||
// SectionPosition headPosition = train.getHeadPosition();
|
|
||||||
// VirtualRealityTrain front = null;
|
|
||||||
// Float distance = null;
|
|
||||||
// for (VirtualRealityTrain other : trainList) {
|
|
||||||
// if (Objects.equals(other, train)) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// SectionPosition otherTrainPosition;
|
|
||||||
// if (Objects.equals(right, other.isRight())) {
|
|
||||||
// // 同向列车,取车尾
|
|
||||||
// otherTrainPosition = other.calculateTailPosition();
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// // 反向列车,取车头
|
|
||||||
// otherTrainPosition = other.getHeadPosition();
|
|
||||||
// }
|
|
||||||
// Float tempDistance = CalculateService.calculateDistance(headPosition, otherTrainPosition, right);
|
|
||||||
// if (Objects.isNull(tempDistance) || tempDistance < 0) {
|
|
||||||
// // 未找到
|
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// if (Objects.isNull(front) || tempDistance < distance) {
|
|
||||||
// front = other;
|
|
||||||
// distance = tempDistance;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// if (Objects.nonNull(front)) {
|
|
||||||
//// log.debug(String.format("列车[%s-%s|%s|%s]前方列车为[%s-%s|%s|%s]",
|
|
||||||
//// train.getGroupNumber(), train.getServiceNumber(),
|
|
||||||
//// train.getTripNumber(), train.getDestinationCode(),
|
|
||||||
//// front.getGroupNumber(), front.getServiceNumber(),
|
|
||||||
//// front.getTripNumber(), front.getDestinationCode()));
|
|
||||||
//// }
|
|
||||||
// return front;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private MovementAuthority.End checkRouteLock(Simulation simulation, Section section, Section tailSection, boolean right, VirtualRealityTrain train) {
|
|
||||||
// if (section.isTransferTrack())
|
|
||||||
// return null;
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// // 判断前方是否有信号机(如果存在信号机,则不判断进路锁闭,以兼容现在列车加载到转换轨没有进路情况)
|
|
||||||
//// Signal aheadSignal = section.getSignalOf(right);
|
|
||||||
//// if (Objects.nonNull(aheadSignal)) {
|
|
||||||
//// return null;
|
|
||||||
//// }
|
|
||||||
// // 先查询是否是已排列的锁闭进路
|
|
||||||
// List<Route> settingRoutes = repository.getSettingRoutes();
|
|
||||||
// boolean lock = false;
|
|
||||||
// if (!CollectionUtils.isEmpty(settingRoutes)) {
|
|
||||||
// for (Route route : settingRoutes) {
|
|
||||||
// if (route.isRouteSection(section)
|
|
||||||
//// && !route.isSetting()
|
|
||||||
// ) {
|
|
||||||
// Signal signal = section.getSignalOf(right);
|
|
||||||
// if (route.isRight() == right || (signal == null || signal.isNormalOpen())) {
|
|
||||||
// lock = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!lock) { // 未找到锁闭进路,判断是否自动信号
|
|
||||||
// Section base = section;
|
|
||||||
// int count = 0;
|
|
||||||
// while (Objects.nonNull(base) && count < 20) {
|
|
||||||
// ++count;
|
|
||||||
// // 向反方向查找,找信号机,判断是否自动信号
|
|
||||||
// Section pre = base.getNextRunningSectionOf(!right);
|
|
||||||
// if (Objects.nonNull(pre)) {
|
|
||||||
// Signal signal = pre.getSignalOf(right);
|
|
||||||
// if (Objects.nonNull(signal)) {
|
|
||||||
// if (signal.isAutoSignal()) {
|
|
||||||
// lock = true; // 如果是自动信号,也相当于锁闭
|
|
||||||
// }
|
|
||||||
// break; // 找到信号机,结束
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// base = pre;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!lock) {
|
|
||||||
// // 未锁闭进路中,设置移动授权终点
|
|
||||||
// return new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
//// // 判断前方是否有信号机(如果存在信号机,则不判断进路锁闭,以兼容现在列车加载到转换轨没有进路情况)
|
|
||||||
//// if (section.isTransferTrack()) {
|
|
||||||
//// return null;
|
|
||||||
//// }
|
|
||||||
////// Signal aheadSignal = section.getSignalOf(right);
|
|
||||||
////// if (Objects.nonNull(aheadSignal)) {
|
|
||||||
////// return null;
|
|
||||||
////// }
|
|
||||||
//// // 先查询是否是已排列的锁闭进路
|
|
||||||
//// List<Route> settingRoutes = repository.getSettingRoutes();
|
|
||||||
//// boolean lock = false;
|
|
||||||
//// if (!CollectionUtils.isEmpty(settingRoutes)) {
|
|
||||||
//// boolean headRoute = false;
|
|
||||||
//// boolean tailRoute = false;
|
|
||||||
//// for (Route route : settingRoutes) {
|
|
||||||
//// if (route.isRight() == right && (route.isRouteSection(section) || route.isRouteSection(tailSection))) {
|
|
||||||
//// if (route.isRouteSection(section))
|
|
||||||
//// headRoute = true;
|
|
||||||
//// if (route.isRouteSection(tailSection))
|
|
||||||
//// tailRoute = true;
|
|
||||||
//// lock = true;
|
|
||||||
//// List<Switch> switches = screenSwitchesInFront(route, tailSection);
|
|
||||||
//// if (!this.checkRouteSwitchPosition(route, switches) || !this.isFlsCheckPass(route.getFlsList(), switches)) {
|
|
||||||
//// return new MovementAuthority.End(section, MovementAuthority.EndType.ROUTE_INTERLOCK_NOT_MET);
|
|
||||||
//// }
|
|
||||||
//// if (headRoute && tailRoute)
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// if (!lock) { // 未找到锁闭进路,判断是否自动信号
|
|
||||||
//// Section base = section;
|
|
||||||
//// int count = 0;
|
|
||||||
//// while (Objects.nonNull(base) && count < 20) {
|
|
||||||
//// ++count;
|
|
||||||
//// // 向反方向查找,找信号机,判断是否自动信号
|
|
||||||
//// Section pre = base.getNextRunningSectionOf(!right);
|
|
||||||
//// if (Objects.nonNull(pre)) {
|
|
||||||
//// Signal signal = pre.getSignalOf(right);
|
|
||||||
//// if (Objects.nonNull(signal)) {
|
|
||||||
//// if (signal.isAutoSignal()) {
|
|
||||||
//// lock = true; // 如果是自动信号,也相当于锁闭
|
|
||||||
//// }
|
|
||||||
//// break; // 找到信号机,结束
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// base = pre;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// if (!lock && section.getSignalOf(right) == null) {
|
|
||||||
//// // 未锁闭进路中,设置移动授权终点
|
|
||||||
//// return new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION);
|
|
||||||
//// }
|
|
||||||
//// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private boolean checkRouteSwitchPosition(Route route, List<Switch> switches) {
|
|
||||||
// List<SwitchElement> collect = route.getSwitchList().stream()
|
|
||||||
// .filter(element -> switches.contains(element.getASwitch()))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// return routeService.checkRouteSwitchPosition(collect);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private boolean isFlsCheckPass(List<RouteFls> flsList, List<Switch> switches) {
|
|
||||||
// if (!CollectionUtils.isEmpty(flsList) && !CollectionUtils.isEmpty(switches)) {
|
|
||||||
// List<RouteFls> collect = flsList.stream().filter(fls -> switches.contains(fls.getBase().getASwitch())).collect(Collectors.toList());
|
|
||||||
// return routeService.isFlsCheckPass(collect);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 筛选前方的道岔
|
|
||||||
// */
|
|
||||||
// private List<Switch> screenSwitchesInFront(Route route, Section section) {
|
|
||||||
// boolean right = route.isRight();
|
|
||||||
// List<Section> sectionList = route.getSectionList();
|
|
||||||
// List<Switch> sectionRelSwitches = new ArrayList<>();
|
|
||||||
// for (int i = 0; i < 10; i++) {
|
|
||||||
// if (sectionList.contains(section))
|
|
||||||
// break;
|
|
||||||
// else
|
|
||||||
// section = section.getNextRunningSectionOf(right);
|
|
||||||
// }
|
|
||||||
// while (sectionList.contains(section)) {
|
|
||||||
// if (section.getRelSwitch() != null)
|
|
||||||
// sectionRelSwitches.add(section.getRelSwitch());
|
|
||||||
// section = section.getNextRunningSectionOf(right);
|
|
||||||
// }
|
|
||||||
// return sectionRelSwitches;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 检查地面真实信号机是否未开放/故障信号机
|
|
||||||
// *
|
|
||||||
// * @param section
|
|
||||||
// * @param right
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// private MovementAuthority.End checkGroundSignal(Section section, boolean right) {
|
|
||||||
// Signal signal = section.getSignalOf(right);
|
|
||||||
// if (Objects.nonNull(signal) && !signal.isVirtual() && !signal.isNormalOpen()) {
|
|
||||||
// return new MovementAuthority.End(signal,
|
|
||||||
// MovementAuthority.EndType.CLOSED_SIGNAL);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 检查是否未开放/故障信号机
|
|
||||||
// *
|
|
||||||
// * @param section
|
|
||||||
// * @param right
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// private MovementAuthority.End checkSignal(Section section, boolean right) {
|
|
||||||
// Signal signal = section.getSignalOf(right);
|
|
||||||
// if (Objects.nonNull(signal) && !signal.isNormalOpen()) {
|
|
||||||
// return new MovementAuthority.End(signal,
|
|
||||||
// MovementAuthority.EndType.CLOSED_SIGNAL);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 检查是否站台屏蔽门开门
|
|
||||||
// */
|
|
||||||
// private MovementAuthority.End checkPsdOpenOrClose(Section section) {
|
|
||||||
// if (section.isStandTrack()) {
|
|
||||||
// List<Stand> standList = section.getStandList();
|
|
||||||
// for (Stand stand : standList) {
|
|
||||||
// if (!stand.isPsdSafe()) {
|
|
||||||
// return new MovementAuthority.End(stand, MovementAuthority.EndType.OPENED_PSD, section);
|
|
||||||
// }
|
|
||||||
// if (stand.isClosed()) {
|
|
||||||
// return new MovementAuthority.End(stand, MovementAuthority.EndType.CLOSED_STAND, section);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// public void addJobs(Simulation simulation) {
|
|
||||||
////// simulation.addJob(SimulationModule.ZC.name(), () -> this.run(simulation), SimulationConstants.ZC_LOOP_RATE);
|
|
||||||
//// simulation.addJob("MaCal", () -> this.maService.calculateMaOfCtcTrains(simulation), 1000);
|
|
||||||
//// }
|
|
||||||
//}
|
|
|
@ -1,59 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 自动信号服务
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class AutoSignalService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 根据连锁关系更新信号显示
|
|
||||||
// * @param simulation
|
|
||||||
// * @param autoSignal
|
|
||||||
// */
|
|
||||||
// public void updateSignalDisplay(Simulation simulation, AutoSignal autoSignal) {
|
|
||||||
// Signal signal = autoSignal.getSignal();
|
|
||||||
// if (!signal.isLogicLight()) {
|
|
||||||
// List<Section> sectionList = autoSignal.getSectionList();
|
|
||||||
// boolean clear = true; // 所有区段是否出清
|
|
||||||
// for (Section section : sectionList) {
|
|
||||||
// if (section.isOccupied()) {
|
|
||||||
// clear = false;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (clear) { // 全部出清,开信号机
|
|
||||||
// this.signalService.openGreenSignal(simulation, signal);
|
|
||||||
// } else { // 关信号机
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!signal.isMainAspect()) {
|
|
||||||
// this.signalService.openGreenSignal(simulation, signal);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// if (!clear) { // 信号机物理点红灯
|
|
||||||
//// if (signal.isLogicLight()) {
|
|
||||||
//// signal.changeLightType(false);
|
|
||||||
//// }
|
|
||||||
//// this.signalService.close(simulation, signal);
|
|
||||||
//// } else { // 信号机开灯
|
|
||||||
//// this.signalService.openGreenSignal(simulation, signal);
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,120 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
|
||||||
//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.map.Signal;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Objects;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 区段服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class SectionService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 封锁(封锁后,包含区段的进路不能排列)
|
|
||||||
// */
|
|
||||||
// public void blockade(Section section) {
|
|
||||||
//// if(section.isRouteLock() || section.isOverlapLock()) {
|
|
||||||
//// log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode()));
|
|
||||||
//// return;
|
|
||||||
//// }
|
|
||||||
// if (!section.isBlockade()) {
|
|
||||||
// section.setBlockade(true);
|
|
||||||
// if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
|
|
||||||
// section.getLogicList().forEach(logic -> logic.setBlockade(true));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 解封
|
|
||||||
// */
|
|
||||||
// public void unblock(Section section) {
|
|
||||||
// if (section.isBlockade()) {
|
|
||||||
// section.setBlockade(false);
|
|
||||||
// if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
|
|
||||||
// section.getLogicList().forEach(logic -> logic.setBlockade(false));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 区故解
|
|
||||||
// */
|
|
||||||
// public void sectionFaultUnlock(Simulation simulation, Section section, Route route) {
|
|
||||||
// if (route != null) {
|
|
||||||
// if (route.isOpenMain()) {
|
|
||||||
// signalService.close(simulation, route.getStart());
|
|
||||||
// }
|
|
||||||
// if (routeService.isApproachLock(simulation.getRepository(), route) || section.isOverlapLock()) {
|
|
||||||
// // 区段延时解锁
|
|
||||||
// int delayTime = route.getDelayReleaseTime() * 1000;
|
|
||||||
// section.delayUnlock(delayTime);
|
|
||||||
// if (section.isShowLogic()) {
|
|
||||||
// section.getLogicList().forEach(ls -> ls.delayUnlock(delayTime));
|
|
||||||
// }
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// route.setLock(false);
|
|
||||||
// Signal start = route.getStart();
|
|
||||||
// if (start.getLockedRoute() == route) {
|
|
||||||
// start.setLockedRoute(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// section.faultUnlock();
|
|
||||||
// if (section.isShowLogic()) {
|
|
||||||
// section.getLogicList().forEach(Section::faultUnlock);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 区段延时区故解
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param section
|
|
||||||
// */
|
|
||||||
// public void delayUnlock(Simulation simulation, Section section) {
|
|
||||||
// int remainTime = section.getDelayTime();
|
|
||||||
// if (remainTime > 0) {
|
|
||||||
// remainTime -= SimulationConstants.CI_LOOP_RATE;
|
|
||||||
// if (remainTime <= 0) {
|
|
||||||
// List<Route> routeList = simulation.getRepository().queryAllLockedRoute();
|
|
||||||
// Route lockedRoute = null;
|
|
||||||
// for (Route route : routeList) {
|
|
||||||
// if (route.containSection(section)) {
|
|
||||||
// lockedRoute = route;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (Objects.nonNull(lockedRoute)) {
|
|
||||||
// lockedRoute.setLock(false);
|
|
||||||
// Signal start = lockedRoute.getStart();
|
|
||||||
// this.signalService.close(simulation, start);
|
|
||||||
// if (start.getLockedRoute() == lockedRoute) {
|
|
||||||
// start.setLockedRoute(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// section.faultUnlock();
|
|
||||||
// section.setDelayTime(0);
|
|
||||||
// } else {
|
|
||||||
// section.setDelayTime(remainTime);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,180 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.ApplicationContext;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Objects;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 信号机服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class SignalService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private VrSignalControlService vrSignalControlService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private ApplicationContext applicationContext;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 封锁(封锁后,包含信号机的进路不能排列)
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void blockade(Simulation simulation, Signal signal) {
|
|
||||||
// if(!signal.isBlockade()) {
|
|
||||||
// signal.setBlockade(true);
|
|
||||||
// this.close(simulation, signal);
|
|
||||||
// if (signal.getLockedRoute() != null) {
|
|
||||||
// signal.setReblockade(true);
|
|
||||||
// log.debug(signal.debugStr() + "因信号机封锁且有锁闭的进路而重复封锁");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 解封
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void unblock(Signal signal) {
|
|
||||||
// if (signal.isBlockade()) {
|
|
||||||
// signal.setBlockade(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 信号关闭
|
|
||||||
// * @param simulation
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void close(Simulation simulation, Signal signal) {
|
|
||||||
// if (signal.isLogicLight()) {
|
|
||||||
// signal.apply(false, false, true);
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.close(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点绿灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void openGreenSignal(Simulation simulation, Signal signal) {
|
|
||||||
// if (signal.isLogicLight()) {
|
|
||||||
// signal.apply(true, false, false);
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.close(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点黄灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void openYellowSignal(Simulation simulation, Signal signal) {
|
|
||||||
// if (signal.isLogicLight()) {
|
|
||||||
// signal.apply(false, true, false);
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.close(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点黄红灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param signal
|
|
||||||
// */
|
|
||||||
// public void openGuideSignal(Simulation simulation, Signal signal) {
|
|
||||||
// signal.changeLightType(false);
|
|
||||||
// this.vrSignalControlService.openGuideSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// signal.apply(false, true, true);
|
|
||||||
// int guideRemain = signal.getGuideRemain();
|
|
||||||
// if (guideRemain > 0) {
|
|
||||||
// signal.guideInfinite();
|
|
||||||
// } else {
|
|
||||||
// signal.guideStart();
|
|
||||||
// }
|
|
||||||
// signal.setInit(false);
|
|
||||||
// if (signal.isReblockade()) {
|
|
||||||
// signal.setReblockade(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 处理信号机接近消息
|
|
||||||
// * @param simulation
|
|
||||||
// * @param signal
|
|
||||||
// * @param approachMessage
|
|
||||||
// */
|
|
||||||
// public void handleApproachMessage(Simulation simulation, Signal signal, SignalApproachMessage approachMessage) {
|
|
||||||
// if (Objects.equals(signal.getApproachMsg(), approachMessage.getApproachMsg())) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// signal.setApproachMsg(approachMessage.getApproachMsg());
|
|
||||||
// if (signal.isNctApproach()) { // 接近区段非通信车占用
|
|
||||||
// this.changeRoutesCBTCMode(simulation, signal, false);
|
|
||||||
// if (signal.isLogicLight()) { // 非通信车占用,改为物理点灯
|
|
||||||
// this.changeSignalLightType(simulation, signal, false);
|
|
||||||
// }
|
|
||||||
// } else if (signal.isCbtcApproach()) { // 接近区段通信车占用
|
|
||||||
// this.changeRoutesCBTCMode(simulation, signal, true);
|
|
||||||
// if (!signal.isLogicLight()) {
|
|
||||||
// this.changeSignalLightType(simulation, signal, true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void changeSignalLightType(Simulation simulation, Signal signal, boolean logic) {
|
|
||||||
// if (!Objects.equals(signal.isLogicLight(), logic)) {
|
|
||||||
// signal.changeLightType(logic);
|
|
||||||
// if (!signal.isLogicLight()) {
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// if (signal.isGreenOpen()) {
|
|
||||||
// this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// } else if (signal.isYellowOpen()) {
|
|
||||||
// this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// } else {
|
|
||||||
// this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!signal.isVirtual()) {
|
|
||||||
// this.vrSignalControlService.close(simulation, signal.getVirtualSignal());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void changeRoutesCBTCMode(Simulation simulation, Signal signal, boolean cbtc) {
|
|
||||||
// List<Route> routeList = signal.getRouteList();
|
|
||||||
// if (!CollectionUtils.isEmpty(routeList)) {
|
|
||||||
// routeList.forEach(route -> route.setCbtcMode(cbtc));
|
|
||||||
// applicationContext.publishEvent(new RouteModeChangeEvent(this, simulation, routeList));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,185 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.PsdSwitch;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.ApplicationContext;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.util.Objects;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 屏蔽门服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class StandService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private ApplicationContext applicationContext;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外屏蔽门开关
|
|
||||||
// */
|
|
||||||
// public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open) {
|
|
||||||
// if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) ||
|
|
||||||
// (!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) {
|
|
||||||
//// log.debug(String.format("屏蔽门[%s(%s)]已经在对应状态,不需要再控制", vrPsd.getName(), vrPsd.getCode()));
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// vrPsd.startSetting(open);
|
|
||||||
// ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open);
|
|
||||||
// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg);
|
|
||||||
// this.applicationContext.publishEvent(event);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 打开屏蔽门
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param psd
|
|
||||||
// */
|
|
||||||
// public void openScreenDoor(Simulation simulation, PSD psd) {
|
|
||||||
// VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor();
|
|
||||||
// if (vrPsd.isPslControl()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// this.controlVrPSD(simulation, vrPsd, true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 关闭屏蔽门
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param psd
|
|
||||||
// */
|
|
||||||
// public void closeScreenDoor(Simulation simulation, PSD psd) {
|
|
||||||
// VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor();
|
|
||||||
// if (vrPsd.isPslControl()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// this.controlVrPSD(simulation, vrPsd, false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 设置扣车
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param stand
|
|
||||||
// * @param center
|
|
||||||
// */
|
|
||||||
// public void holdTrain(Simulation simulation, Stand stand, boolean center) {
|
|
||||||
// if (center) {
|
|
||||||
// stand.setCenterHoldTrain(true);
|
|
||||||
// } else {
|
|
||||||
// stand.setStationHoldTrain(true);
|
|
||||||
// }
|
|
||||||
// // 关闭出站信号机
|
|
||||||
// Signal signal = stand.getSection().getSignalOf(stand.isRight());
|
|
||||||
// if (Objects.nonNull(signal)) {
|
|
||||||
// MapConfig config = simulation.getRepository().getConfig();
|
|
||||||
// if (config.isStandHoldCloseLogicLight()/* || !signal.isLogicLight()*/) {
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**系统扣车*/
|
|
||||||
// public void sysHoldTrain(Simulation simulation, Stand stand) {
|
|
||||||
// stand.setSysHoldTrain(true);
|
|
||||||
// // 关闭出站信号机
|
|
||||||
// Signal signal = stand.getSection().getSignalOf(stand.isRight());
|
|
||||||
// if (Objects.nonNull(signal)) {
|
|
||||||
// MapConfig config = simulation.getRepository().getConfig();
|
|
||||||
// if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) {
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void cancelSysHoldTrain(Simulation simulation, Stand stand) {
|
|
||||||
// stand.setSysHoldTrain(false);
|
|
||||||
// // 如果所有扣车都取消,开放出站信号机
|
|
||||||
// if (!stand.isHoldTrain()) {
|
|
||||||
// this.reopenSignal(simulation, stand);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void ibpHoldTrain(Simulation simulation, Stand stand) {
|
|
||||||
// stand.setIbpHoldTrain(true);
|
|
||||||
// // 关闭出站信号机
|
|
||||||
// Signal signal = stand.getSection().getSignalOf(stand.isRight());
|
|
||||||
// if (Objects.nonNull(signal)) {
|
|
||||||
// MapConfig config = simulation.getRepository().getConfig();
|
|
||||||
// if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) {
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void cancelIbpHoldTrain(Simulation simulation, Stand stand) {
|
|
||||||
// stand.setIbpHoldTrain(false);
|
|
||||||
// // 如果所有扣车都取消,开放出站信号机
|
|
||||||
// if (!stand.isHoldTrain()) {
|
|
||||||
// this.reopenSignal(simulation, stand);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 取消扣车
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// * @param stand
|
|
||||||
// * @param center
|
|
||||||
// */
|
|
||||||
// public void cancelHoldTrain(Simulation simulation, Stand stand, boolean center) {
|
|
||||||
// if (center) {
|
|
||||||
// stand.setCenterHoldTrain(false);
|
|
||||||
// } else {
|
|
||||||
// stand.setStationHoldTrain(false);
|
|
||||||
// }
|
|
||||||
// // 如果所有扣车都取消,开放出站信号机
|
|
||||||
// if (!stand.isHoldTrain()) {
|
|
||||||
// this.reopenSignal(simulation, stand);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void cancelAllHoldTrain(Simulation simulation, Stand stand) {
|
|
||||||
// stand.setCenterHoldTrain(false);
|
|
||||||
// stand.setStationHoldTrain(false);
|
|
||||||
// this.reopenSignal(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void reopenSignal(Simulation simulation, Stand stand) {
|
|
||||||
// Signal signal = stand.getSection().getSignalOf(stand.isRight());
|
|
||||||
// if (Objects.nonNull(signal) && !signal.isMainAspect()) {
|
|
||||||
// Route lockedRoute = signal.getLockedRoute();
|
|
||||||
// if (Objects.nonNull(lockedRoute) && this.routeService.isInterlocked(lockedRoute)) { // 锁闭进路存在,开信号机
|
|
||||||
// this.routeService.routeOpen(simulation, lockedRoute);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 设置或取消互锁解除
|
|
||||||
// * @param release 是否是设置
|
|
||||||
// */
|
|
||||||
// public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) {
|
|
||||||
// stand.getPsd().getVirtualScreenDoor().updateIL(release);
|
|
||||||
// stand.getPsd().setInterlockRelease(release);
|
|
||||||
// if (release) {
|
|
||||||
// this.reopenSignal(simulation, stand);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,263 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.SwitchTurn;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.ApplicationContext;
|
|
||||||
//import org.springframework.context.event.EventListener;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Objects;
|
|
||||||
//import java.util.Random;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 道岔服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class SwitchService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private ApplicationContext applicationContext;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SectionService sectionService;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外道岔转动(道岔转动指令下达)
|
|
||||||
// * @param simulation
|
|
||||||
// * @param aSwitch
|
|
||||||
// * @param toNormal
|
|
||||||
// */
|
|
||||||
// public void controlSwitch(Simulation simulation, Switch aSwitch, boolean toNormal) {
|
|
||||||
// if (simulation.getRepository().getConfig().isSwitchTurnOperationCanRecoverSplitFault()) {
|
|
||||||
// if (new Random().nextInt(3) == 0) {
|
|
||||||
// Switch.SwitchFault.SPLIT.fix(aSwitch);
|
|
||||||
// Switch.SwitchFault.NORMAL_SPLIT.fix(aSwitch);
|
|
||||||
// Switch.SwitchFault.REVERSE_SPLIT.fix(aSwitch);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
|
|
||||||
// if ((virtualSwitch.isNormal() && toNormal) ||
|
|
||||||
// (virtualSwitch.isReverse() && !toNormal)) {
|
|
||||||
// log.debug(String.format("道岔[%s]已经在指定位置[%s],无需转动", aSwitch.debugStr(), virtualSwitch.isNormal()?"N":"R"));
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (virtualSwitch.isSettingTo(toNormal)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// // 向虚拟室外设备发送转换指令
|
|
||||||
// virtualSwitch.startSetting(toNormal);
|
|
||||||
// ControllableDevice ctrlMsg = new SwitchTurn(virtualSwitch, toNormal);
|
|
||||||
// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg);
|
|
||||||
// this.applicationContext.publishEvent(event);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔定操
|
|
||||||
// * @param simulation
|
|
||||||
// * @param aSwitch
|
|
||||||
// */
|
|
||||||
// public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) {
|
|
||||||
// if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// this.controlSwitch(simulation, aSwitch, true);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔反操
|
|
||||||
// * @param simulation
|
|
||||||
// * @param aSwitch
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) {
|
|
||||||
// if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// this.controlSwitch(simulation, aSwitch, false);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔单锁
|
|
||||||
// * @param aSwitch
|
|
||||||
// */
|
|
||||||
// public void singleLock(Switch aSwitch) {
|
|
||||||
// if (!aSwitch.isSingleLock()) {
|
|
||||||
// aSwitch.setSingleLock(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔单解
|
|
||||||
// * @param aSwitch
|
|
||||||
// */
|
|
||||||
// public void singleUnlock(Switch aSwitch) {
|
|
||||||
// if (aSwitch.isSingleLock()) {
|
|
||||||
// aSwitch.setSingleLock(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 封锁(封锁后,包含道岔的进路不能排列)
|
|
||||||
// * @param aSwitch
|
|
||||||
// */
|
|
||||||
// public void blockade(Switch aSwitch) {
|
|
||||||
// if(!aSwitch.isBlockade()) {
|
|
||||||
// aSwitch.setBlockade(true);
|
|
||||||
// aSwitch.getA().setBlockade(true);
|
|
||||||
// aSwitch.getB().setBlockade(true);
|
|
||||||
// aSwitch.getC().setBlockade(true);
|
|
||||||
// }
|
|
||||||
// aSwitch.setInit(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 解封
|
|
||||||
// * @param aSwitch
|
|
||||||
// */
|
|
||||||
// public void unblock(Switch aSwitch) {
|
|
||||||
// if(aSwitch.isBlockade()) {
|
|
||||||
// aSwitch.setBlockade(false);
|
|
||||||
// aSwitch.getA().setBlockade(false);
|
|
||||||
// aSwitch.getB().setBlockade(false);
|
|
||||||
// aSwitch.getC().setBlockade(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔区段故障解锁
|
|
||||||
// * @param simulation
|
|
||||||
// * @param aSwitch
|
|
||||||
// * @param route
|
|
||||||
// */
|
|
||||||
// public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) {
|
|
||||||
// if (route != null) {
|
|
||||||
// if (route.isOpenMain()) {
|
|
||||||
// signalService.close(simulation, route.getStart());
|
|
||||||
// }
|
|
||||||
// if (routeService.isApproachLock(simulation.getRepository(), route) || aSwitch.isOverlapLock()) {
|
|
||||||
// // 延时解锁
|
|
||||||
// aSwitch.setDelayTime(route.getDelayReleaseTime() * 1000);
|
|
||||||
// aSwitch.getAllSections().forEach(section -> {
|
|
||||||
// if (section.isLocked())
|
|
||||||
// sectionService.sectionFaultUnlock(simulation, section, route);
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// route.setLock(false);
|
|
||||||
// Signal start = route.getStart();
|
|
||||||
// if (start.getLockedRoute() == route) {
|
|
||||||
// start.setLockedRoute(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.faultUnlock(aSwitch, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void faultUnlock(Switch aSwitch, Route route) {
|
|
||||||
// aSwitch.faultUnlock();
|
|
||||||
// aSwitch.sectionFaultUnlock();
|
|
||||||
// if (route != null) {
|
|
||||||
// route.unlockRouteFlsOfSwitch(aSwitch); //进路中该道岔对应的侧防解除锁闭
|
|
||||||
// RouteOverlap overlap = route.getOverlap();
|
|
||||||
// if (overlap != null) {
|
|
||||||
// for (SectionPath sectionPath : overlap.getPathList()) {
|
|
||||||
// overlap.unlockFlsOfSwitch(sectionPath.getFlsList(), aSwitch); //延续保护中该道岔的侧防解除锁闭
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void delayUnlock(Simulation simulation, Switch aSwitch) {
|
|
||||||
// int remainTime = aSwitch.getDelayTime();
|
|
||||||
// if (remainTime > 0) {
|
|
||||||
// remainTime -= SimulationConstants.CI_LOOP_RATE;
|
|
||||||
// if (remainTime <= 0) {
|
|
||||||
// List<Route> routeList = simulation.getRepository().queryAllLockedRoute();
|
|
||||||
// Route lockedRoute = null;
|
|
||||||
// if (aSwitch.isRouteLock()) {
|
|
||||||
// lockedRoute = aSwitch.getRoute();
|
|
||||||
// } else {
|
|
||||||
// for (Route route : routeList) {
|
|
||||||
// if (route.overlapContainSwitch(aSwitch)) {
|
|
||||||
// lockedRoute = route;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (Objects.nonNull(lockedRoute)) {
|
|
||||||
// lockedRoute.setLock(false);
|
|
||||||
// Signal start = lockedRoute.getStart();
|
|
||||||
// if (start.getLockedRoute() == lockedRoute) {
|
|
||||||
// start.setLockedRoute(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.faultUnlock(aSwitch, lockedRoute);
|
|
||||||
// aSwitch.setDelayTime(0);
|
|
||||||
// } else {
|
|
||||||
// aSwitch.setDelayTime(remainTime);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @EventListener
|
|
||||||
// public void handle(RouteModeChangeEvent event) {
|
|
||||||
// this.switchStatusUpdate(event.getSimulation(), event.getRoutes());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 道岔的封锁失效状态更新
|
|
||||||
// */
|
|
||||||
// private void switchStatusUpdate(Simulation simulation, List<Route> routes) {
|
|
||||||
// if (!simulation.getRepository().getConfig().isBlockadeCommandOnlyValidInStandbyMode()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (!CollectionUtils.isEmpty(routes)) {
|
|
||||||
// if (!routes.get(0).isCbtcMode()) { //进路的状态被设为非cbtc
|
|
||||||
// routes.forEach(route -> {
|
|
||||||
// route.getSwitchList().forEach(switchElement -> {
|
|
||||||
// Switch aSwitch = switchElement.getASwitch();
|
|
||||||
// if (aSwitch.isBlockade()) {
|
|
||||||
// aSwitch.setBlockadeInvalid(false);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// List<Switch> switches = routes.stream()
|
|
||||||
// .flatMap(route -> route.getSwitchList()
|
|
||||||
// .stream()
|
|
||||||
// .map(SwitchElement::getASwitch)
|
|
||||||
// .filter(aSwitch -> aSwitch.isBlockade() && !aSwitch.isBlockadeInvalid()))
|
|
||||||
// .collect(Collectors.toList()); //进路下所有处于封锁且封锁有效状态的道岔
|
|
||||||
// for (Route route : simulation.getRepository().getRouteList()) {
|
|
||||||
// if (!route.isCbtcMode()) {
|
|
||||||
// switches.removeIf(route::isRouteSwitch);
|
|
||||||
// if (switches.isEmpty()) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// switches.forEach(aSwitch -> aSwitch.setBlockadeInvalid(true));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,100 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.CI.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.communication.vo.SignalLight;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.ApplicationContext;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.util.Objects;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 信号机服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class VrSignalControlService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private ApplicationContext applicationContext;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机灭灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// */
|
|
||||||
// public void close(Simulation simulation, VirtualRealitySignal vrSignal) {
|
|
||||||
// if (!vrSignal.isBlack()) {
|
|
||||||
// this.controlRealSignal(simulation, vrSignal, false, false, false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点绿灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// */
|
|
||||||
// public void openGreenSignal(Simulation simulation, VirtualRealitySignal vrSignal) {
|
|
||||||
// controlRealSignal(simulation, vrSignal, true, false, false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点黄灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// */
|
|
||||||
// public void openYellowSignal(Simulation simulation, VirtualRealitySignal vrSignal) {
|
|
||||||
// controlRealSignal(simulation, vrSignal, false, true, false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点红灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// */
|
|
||||||
// public void openRedSignal(Simulation simulation, VirtualRealitySignal vrSignal) {
|
|
||||||
// controlRealSignal(simulation, vrSignal, false, false, true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号机点黄红灯
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// */
|
|
||||||
// public void openGuideSignal(Simulation simulation, VirtualRealitySignal vrSignal) {
|
|
||||||
// this.controlRealSignal(simulation, vrSignal, false, true, true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 控制室外信号灯显示
|
|
||||||
// * @param simulation
|
|
||||||
// * @param vrSignal
|
|
||||||
// * @param greenOpen
|
|
||||||
// * @param yellowOpen
|
|
||||||
// * @param redOpen
|
|
||||||
// */
|
|
||||||
// private void controlRealSignal(Simulation simulation, VirtualRealitySignal vrSignal,
|
|
||||||
// boolean greenOpen, boolean yellowOpen, boolean redOpen) {
|
|
||||||
// // 根据点灯类型,和要开放信号,下达信号机控制指令
|
|
||||||
// if(Objects.isNull(vrSignal)){
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (!vrSignal.isSame(greenOpen, yellowOpen, redOpen)) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(vrSignal.getCode(), Signal.class);
|
|
||||||
// if (signal.isFault()) {
|
|
||||||
// vrSignal.apply(false, false, true);
|
|
||||||
// } else {
|
|
||||||
// vrSignal.apply(greenOpen, yellowOpen, redOpen);
|
|
||||||
// }
|
|
||||||
// ControllableDevice ctrlMsg = new SignalLight(vrSignal);
|
|
||||||
// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg);
|
|
||||||
// this.applicationContext.publishEvent(event);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,39 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.ISCS;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.services.voice.VoiceService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
|
||||||
//import club.joylink.rtss.vo.client.iscs.Ats2PisMsg;
|
|
||||||
//import club.joylink.rtss.vo.client.voice.BaseVoiceSynthesisVO;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * PIS系统逻辑服务
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//public class OnBoardPisService {
|
|
||||||
// /*@Autowired
|
|
||||||
// @Qualifier("baiDuVoiceService")
|
|
||||||
// private IVoiceService iVoiceService;*/
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
//// @Qualifier("baiDuVoiceService2")
|
|
||||||
// private VoiceService iVoiceService;
|
|
||||||
// public void play(Simulation simulation, Ats2PisMsg msg) {
|
|
||||||
// String content;
|
|
||||||
// if (msg.isArrivalMsg()) {
|
|
||||||
// String direction = msg.getStand().isInside() ? "左" : "右";
|
|
||||||
// content = msg.getStation().getName() + "站到了,下车的乘客请从列车运行方向的" + direction + "侧车门下车";
|
|
||||||
// } else {
|
|
||||||
// content = "本次列车开往" + msg.getTerminalStation().getName() + "方向,下一站" + msg.getStation().getName();
|
|
||||||
// }
|
|
||||||
// BaseVoiceSynthesisVO vo = new BaseVoiceSynthesisVO(content);
|
|
||||||
// String path = iVoiceService.synthesis(vo).getFilePath();
|
|
||||||
//// String path = iVoiceService.synthesis(content);
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// VirtualRealityTrain train = repository.getOnlineTrainBy(msg.getGroupNumber());
|
|
||||||
// train.getVrAudio().updateUrl(path);
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -8,78 +8,82 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
||||||
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
public interface SimulationService {
|
public interface SimulationService {
|
||||||
/**
|
|
||||||
* 创建仿真
|
|
||||||
*/
|
|
||||||
String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 给仿真添加功能
|
* 创建仿真
|
||||||
*/
|
*/
|
||||||
void addItems(String simulationId, Map<SimulationWorkParamVO.Item, String> itemMap);
|
String createSimulation(long mapId, SimulationWorkParamVO workParamVO,
|
||||||
|
@NonNull LoginUserInfoVO loginUserInfoVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从仿真中移除功能
|
* 给仿真添加功能
|
||||||
*/
|
*/
|
||||||
void removeItems(String simulationId, List<SimulationWorkParamVO.Item> items, LoginUserInfoVO loginInfo);
|
void addItems(String simulationId, Map<SimulationWorkParamVO.Item, String> itemMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按计划行车
|
* 从仿真中移除功能
|
||||||
*/
|
*/
|
||||||
void runAsPlan(String simulationId, RunAsPlanParam param);
|
void removeItems(String simulationId, List<SimulationWorkParamVO.Item> items,
|
||||||
|
LoginUserInfoVO loginInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置仿真
|
* 按计划行车
|
||||||
*/
|
*/
|
||||||
void reset(String simulationId);
|
void runAsPlan(String simulationId, RunAsPlanParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据地图和功能ID获取仿真GroupId
|
* 重置仿真
|
||||||
*
|
*/
|
||||||
* @param mapId 地图ID
|
void reset(String simulationId);
|
||||||
* @param mapFunctionId 功能ID
|
|
||||||
* @return 仿真GroupId
|
/**
|
||||||
*/
|
* 根据地图和功能ID获取仿真GroupId
|
||||||
String querySimulationByMapIdAndMapFunction(long mapId, long mapFunctionId);
|
*
|
||||||
|
* @param mapId 地图ID
|
||||||
|
* @param mapFunctionId 功能ID
|
||||||
|
* @return 仿真GroupId
|
||||||
|
*/
|
||||||
|
String querySimulationByMapIdAndMapFunction(long mapId, long mapFunctionId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据地图和功能ID获取仿真GroupId返回仿真对象
|
* 根据地图和功能ID获取仿真GroupId返回仿真对象
|
||||||
*
|
*
|
||||||
* @param mapId 地图ID
|
* @param mapId 地图ID
|
||||||
* @param mapFunctionId 功能ID
|
* @param mapFunctionId 功能ID
|
||||||
* @return 仿真GroupId
|
* @return 仿真GroupId
|
||||||
*/
|
*/
|
||||||
Simulation querySimulation(long mapId, long mapFunctionId);
|
Simulation querySimulation(long mapId, long mapFunctionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监控仿真
|
* 监控仿真
|
||||||
*/
|
*/
|
||||||
void monitor(String simulationId, AccountVO user);
|
void monitor(String simulationId, AccountVO user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后台创建仿真
|
* 后台创建仿真
|
||||||
*
|
*
|
||||||
* @param mapFunctionId mapFunctionId 功能ID
|
* @param mapFunctionId mapFunctionId 功能ID
|
||||||
* @param loginInfo 登录信息
|
* @param loginInfo 登录信息
|
||||||
* @param checkAuth 是否检查权限
|
* @param checkAuth 是否检查权限
|
||||||
* @return 仿真对象
|
* @return 仿真对象
|
||||||
*/
|
*/
|
||||||
Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth);
|
Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth);
|
||||||
|
|
||||||
void loadDraftRunPlan(String simulationId, long draftRunPlanId);
|
void loadDraftRunPlan(String simulationId, long draftRunPlanId);
|
||||||
|
|
||||||
SimulationVO querySimulationJoinedByUser(long userId);
|
SimulationVO querySimulationJoinedByUser(long userId);
|
||||||
|
|
||||||
List<SimulationInfoVO> listSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
|
List<SimulationInfoVO> listSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
|
||||||
|
|
||||||
PageVO<SimulationInfoVO> pagedSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
|
PageVO<SimulationInfoVO> pagedSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
|
||||||
|
|
||||||
void sendUnreceivedMessages(String simulationId, String memberId);
|
void sendUnreceivedMessages(String simulationId, String memberId);
|
||||||
|
|
||||||
|
List<SimulationInfoVO> listAllSimulation(SimulationInfoQueryVO queryVO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,15 @@ import club.joylink.rtss.vo.permission.subject.PermissionSubjectVO;
|
||||||
import club.joylink.rtss.websocket.StompMessageService;
|
import club.joylink.rtss.websocket.StompMessageService;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -42,58 +51,58 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SimulationServiceImpl implements SimulationService {
|
public class SimulationServiceImpl implements SimulationService {
|
||||||
@Autowired
|
|
||||||
private SimulationManager simulationManager;
|
|
||||||
@Autowired
|
|
||||||
private SimulationWorkServiceManager simulationWorkServiceManager;
|
|
||||||
@Autowired
|
|
||||||
private GroupSimulationService groupSimulationService;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationContext applicationContext;
|
|
||||||
@Autowired
|
|
||||||
private DefaultMessageSender defaultMessageSender;
|
|
||||||
@Autowired
|
|
||||||
private RtsMapFunctionService rtsMapFunctionService;
|
|
||||||
@Autowired
|
|
||||||
private StompMessageService stompMessageService;
|
|
||||||
@Autowired
|
|
||||||
private RunPlanDraftService runPlanDraftService;
|
|
||||||
@Autowired
|
|
||||||
private SimulationLifeCycleService simulationLifeCycleService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PermissionSubjectService subjectService;
|
private SimulationManager simulationManager;
|
||||||
|
@Autowired
|
||||||
|
private SimulationWorkServiceManager simulationWorkServiceManager;
|
||||||
|
@Autowired
|
||||||
|
private GroupSimulationService groupSimulationService;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
@Autowired
|
||||||
|
private DefaultMessageSender defaultMessageSender;
|
||||||
|
@Autowired
|
||||||
|
private RtsMapFunctionService rtsMapFunctionService;
|
||||||
|
@Autowired
|
||||||
|
private StompMessageService stompMessageService;
|
||||||
|
@Autowired
|
||||||
|
private RunPlanDraftService runPlanDraftService;
|
||||||
|
@Autowired
|
||||||
|
private SimulationLifeCycleService simulationLifeCycleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService iSysUserService;
|
private PermissionSubjectService subjectService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVoiceDiscriminateRule discriminateRule;
|
private ISysUserService iSysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IVoiceDiscriminateRule discriminateRule;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) {
|
public String createSimulation(long mapId, SimulationWorkParamVO workParamVO,
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(workParamVO.containsRealDeviceItem(), "此途径创建的仿真不能连接真实设备");
|
@NonNull LoginUserInfoVO loginUserInfoVO) {
|
||||||
return createSimulation(mapId, null, workParamVO, loginUserInfoVO, null).getId();
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(workParamVO.containsRealDeviceItem(),
|
||||||
}
|
"此途径创建的仿真不能连接真实设备");
|
||||||
|
return createSimulation(mapId, null, workParamVO, loginUserInfoVO, null).getId();
|
||||||
|
}
|
||||||
|
|
||||||
//只获取所有与该功能相关的权限信息
|
//只获取所有与该功能相关的权限信息
|
||||||
private List<PermissionSubjectVO> filterUserPermission(List<PermissionSubjectVO> subjectVOList, MapFunctionVO functionVO, LoginUserInfoVO loginUserInfoVO) {
|
private List<PermissionSubjectVO> filterUserPermission(List<PermissionSubjectVO> subjectVOList,
|
||||||
List<PermissionSubjectVO> newVoList = Lists.newArrayList();
|
MapFunctionVO functionVO, LoginUserInfoVO loginUserInfoVO) {
|
||||||
for (PermissionSubjectVO subjectVO : subjectVOList) {
|
List<PermissionSubjectVO> newVoList = Lists.newArrayList();
|
||||||
if (subjectVO.getStartTime().isAfter(LocalDateTime.now())) {
|
for (PermissionSubjectVO subjectVO : subjectVOList) {
|
||||||
log.info("权限主体id:[{}] 用户id:[{}] 开始时间:[{}]未到时间", subjectVO.getId(), subjectVO.getSubjectId(), subjectVO.getStartTime());
|
if (subjectVO.getStartTime().isAfter(LocalDateTime.now())) {
|
||||||
continue;
|
log.info("权限主体id:[{}] 用户id:[{}] 开始时间:[{}]未到时间", subjectVO.getId(),
|
||||||
}
|
subjectVO.getSubjectId(), subjectVO.getStartTime());
|
||||||
if (!CollectionUtils.isEmpty(subjectVO.getSystemAbilityList())) {
|
continue;
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(subjectVO.getSystemAbilityList())) {
|
||||||
/* if(Objects.equals(PermissionTypeEnum.PROJECT.getValue(),subjectVO.getPermissionType())){
|
/* if(Objects.equals(PermissionTypeEnum.PROJECT.getValue(),subjectVO.getPermissionType())){
|
||||||
if(Objects.equals(subjectVO.getPermissionProjectCode(),loginUserInfoVO.getProject().toLowerCase())){
|
if(Objects.equals(subjectVO.getPermissionProjectCode(),loginUserInfoVO.getProject().toLowerCase())){
|
||||||
newVoList.add(subjectVO);
|
newVoList.add(subjectVO);
|
||||||
|
@ -104,285 +113,339 @@ public class SimulationServiceImpl implements SimulationService {
|
||||||
newVoList.add(subjectVO);
|
newVoList.add(subjectVO);
|
||||||
}
|
}
|
||||||
}else{*/
|
}else{*/
|
||||||
for (PermissionSystemAbilityVO permissionSystemAbilityVO : subjectVO.getSystemAbilityList()) {
|
for (PermissionSystemAbilityVO permissionSystemAbilityVO : subjectVO.getSystemAbilityList()) {
|
||||||
if (Objects.equals(permissionSystemAbilityVO.getAbilityId(), functionVO.getId())) {
|
if (Objects.equals(permissionSystemAbilityVO.getAbilityId(), functionVO.getId())) {
|
||||||
newVoList.add(subjectVO);
|
newVoList.add(subjectVO);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
log.error("权限主体对应的功能是空 主体id:[{}],subjectId:[{}],subjectType:[{}]", subjectVO.getId(), subjectVO.getSubjectId(), subjectVO.getSubjectType());
|
log.error("权限主体对应的功能是空 主体id:[{}],subjectId:[{}],subjectType:[{}]",
|
||||||
}
|
subjectVO.getId(), subjectVO.getSubjectId(), subjectVO.getSubjectType());
|
||||||
}
|
}
|
||||||
return newVoList;
|
}
|
||||||
|
return newVoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测用户对应的权限是否满足
|
||||||
|
*
|
||||||
|
* @param functionVO
|
||||||
|
* @param loginInfo
|
||||||
|
*/
|
||||||
|
private Map<String, Boolean> checkUserPermission(MapFunctionVO functionVO,
|
||||||
|
LoginUserInfoVO loginInfo) {
|
||||||
|
if (loginInfo.getAccountVO().isAdmin()) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
LoginUserInfoVO newLoginUser = loginInfo;
|
||||||
|
if (loginInfo.getAccountVO().isThirdChildAccount()) {
|
||||||
|
AccountVO user = this.iSysUserService.queryUserByAccountForMaster(
|
||||||
|
loginInfo.getAccountVO().getParentAccount());
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(user),
|
||||||
|
"未找到主账号相关权限");
|
||||||
|
newLoginUser = new LoginUserInfoVO();
|
||||||
|
user.setCompanyId(loginInfo.getAccountVO().getCompanyId());
|
||||||
|
newLoginUser.setAccountVO(user);
|
||||||
|
newLoginUser.setProjectInfo(loginInfo.getProjectInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
List<PermissionSubjectVO> subjectVOList = this.subjectService.findPermissionWithMapIdAndUserInfo(
|
||||||
* 检测用户对应的权限是否满足
|
functionVO.getMapId(), newLoginUser);
|
||||||
*
|
|
||||||
* @param functionVO
|
|
||||||
* @param loginInfo
|
|
||||||
*/
|
|
||||||
private Map<String, Boolean> checkUserPermission(MapFunctionVO functionVO, LoginUserInfoVO loginInfo) {
|
|
||||||
if (loginInfo.getAccountVO().isAdmin()) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
LoginUserInfoVO newLoginUser = loginInfo;
|
|
||||||
if (loginInfo.getAccountVO().isThirdChildAccount()) {
|
|
||||||
AccountVO user = this.iSysUserService.queryUserByAccountForMaster(loginInfo.getAccountVO().getParentAccount());
|
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(user), "未找到主账号相关权限");
|
|
||||||
newLoginUser = new LoginUserInfoVO();
|
|
||||||
user.setCompanyId(loginInfo.getAccountVO().getCompanyId());
|
|
||||||
newLoginUser.setAccountVO(user);
|
|
||||||
newLoginUser.setProjectInfo(loginInfo.getProjectInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<PermissionSubjectVO> subjectVOList = this.subjectService.findPermissionWithMapIdAndUserInfo(functionVO.getMapId(), newLoginUser);
|
List<PermissionSubjectVO> newVOLIst = this.filterUserPermission(subjectVOList, functionVO,
|
||||||
|
newLoginUser);
|
||||||
List<PermissionSubjectVO> newVOLIst = this.filterUserPermission(subjectVOList, functionVO, newLoginUser);
|
if (CollectionUtils.isEmpty(newVOLIst)) {
|
||||||
if (CollectionUtils.isEmpty(newVOLIst)) {
|
log.error("未找到对应的权限数据mapId[{}],functionId[{}],userId[{}]", functionVO.getMapId(),
|
||||||
log.error("未找到对应的权限数据mapId[{}],functionId[{}],userId[{}]", functionVO.getMapId(), functionVO.getId(), newLoginUser.getAccountVO().getId());
|
functionVO.getId(), newLoginUser.getAccountVO().getId());
|
||||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(true, "未找到该权限");
|
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(true, "未找到该权限");
|
||||||
}
|
|
||||||
Map<String, Boolean> resultMap2 = Maps.newHashMap();
|
|
||||||
Map<String, List<PermissionSubjectVO>> subjectMapList = newVOLIst.stream().collect(Collectors.groupingBy(PermissionSubjectVO::getSubjectType));
|
|
||||||
for (PermissionSubjectTypeEnum st : PermissionSubjectTypeEnum.SORT_ENUM) {
|
|
||||||
List<PermissionSubjectVO> tmpSubjectVOList = subjectMapList.get(st.name());
|
|
||||||
if (CollectionUtils.isEmpty(tmpSubjectVOList)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<PermissionSubjectVO> canUseSubjectList = this.findCanUsedPermission(tmpSubjectVOList, functionVO, loginInfo);
|
|
||||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(CollectionUtils.isEmpty(canUseSubjectList), "该权限过期");
|
|
||||||
for (PermissionSubjectVO subjectVO : canUseSubjectList) {
|
|
||||||
String key = String.format("%s-%s", st.name(), subjectVO.getId());
|
|
||||||
List<Simulation> findSimList = this.simulationManager.finder(key);
|
|
||||||
resultMap2.put(key, false);
|
|
||||||
if (findSimList.size() + 1 <= subjectVO.getAmount()) {
|
|
||||||
resultMap2.put(key, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resultMap2.values().stream().anyMatch(d -> Objects.equals(true, d))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(resultMap2.values().stream().allMatch(d -> Objects.equals(false, d)), "仿真生成数量过载");
|
|
||||||
return resultMap2;
|
|
||||||
}
|
}
|
||||||
|
Map<String, Boolean> resultMap2 = Maps.newHashMap();
|
||||||
private List<PermissionSubjectVO> findCanUsedPermission(List<PermissionSubjectVO> newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo) {
|
Map<String, List<PermissionSubjectVO>> subjectMapList = newVOLIst.stream()
|
||||||
List<PermissionSubjectVO> canUseSubjectList = newVOLIst.stream().filter(d -> Objects.equals(true, d.getForever())).collect(Collectors.toList());
|
.collect(Collectors.groupingBy(PermissionSubjectVO::getSubjectType));
|
||||||
if (CollectionUtils.isEmpty(canUseSubjectList)) {
|
for (PermissionSubjectTypeEnum st : PermissionSubjectTypeEnum.SORT_ENUM) {
|
||||||
List<Long> timeOverIdList = newVOLIst.stream().filter(d -> Objects.nonNull(d.getEndTime()) && d.getEndTime().isAfter(LocalDateTime.now()))
|
List<PermissionSubjectVO> tmpSubjectVOList = subjectMapList.get(st.name());
|
||||||
.map(d -> d.getId())
|
if (CollectionUtils.isEmpty(tmpSubjectVOList)) {
|
||||||
.collect(Collectors.toList());
|
continue;
|
||||||
if (CollectionUtils.isEmpty(timeOverIdList)) {
|
}
|
||||||
log.error("mapId[{}],functionId[{}] userId[{}] 权限过期", functionVO.getMapId(), functionVO.getId(), loginInfo.getAccountVO().getId());
|
List<PermissionSubjectVO> canUseSubjectList = this.findCanUsedPermission(tmpSubjectVOList,
|
||||||
return Collections.emptyList();
|
functionVO, loginInfo);
|
||||||
}
|
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(
|
||||||
canUseSubjectList = newVOLIst.stream().filter(d -> timeOverIdList.contains(d.getId())).collect(Collectors.toList());
|
CollectionUtils.isEmpty(canUseSubjectList), "该权限过期");
|
||||||
|
for (PermissionSubjectVO subjectVO : canUseSubjectList) {
|
||||||
|
String key = String.format("%s-%s", st.name(), subjectVO.getId());
|
||||||
|
List<Simulation> findSimList = this.simulationManager.finder(key);
|
||||||
|
resultMap2.put(key, false);
|
||||||
|
if (findSimList.size() + 1 <= subjectVO.getAmount()) {
|
||||||
|
resultMap2.put(key, true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return canUseSubjectList;
|
}
|
||||||
|
if (resultMap2.values().stream().anyMatch(d -> Objects.equals(true, d))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(
|
||||||
|
resultMap2.values().stream().allMatch(d -> Objects.equals(false, d)), "仿真生成数量过载");
|
||||||
|
return resultMap2;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private List<PermissionSubjectVO> findCanUsedPermission(List<PermissionSubjectVO> newVOLIst,
|
||||||
public void addItems(@NonNull String simulationId, Map<SimulationWorkParamVO.Item, String> itemMap) {
|
MapFunctionVO functionVO, LoginUserInfoVO loginInfo) {
|
||||||
if (!CollectionUtils.isEmpty(itemMap)) {
|
List<PermissionSubjectVO> canUseSubjectList = newVOLIst.stream()
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
.filter(d -> Objects.equals(true, d.getForever())).collect(Collectors.toList());
|
||||||
Simulation.Type simulationType = simulation.getType();
|
if (CollectionUtils.isEmpty(canUseSubjectList)) {
|
||||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(simulationType);
|
List<Long> timeOverIdList = newVOLIst.stream().filter(
|
||||||
|
d -> Objects.nonNull(d.getEndTime()) && d.getEndTime().isAfter(LocalDateTime.now()))
|
||||||
|
.map(d -> d.getId())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(timeOverIdList)) {
|
||||||
|
log.error("mapId[{}],functionId[{}] userId[{}] 权限过期", functionVO.getMapId(),
|
||||||
|
functionVO.getId(), loginInfo.getAccountVO().getId());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
canUseSubjectList = newVOLIst.stream().filter(d -> timeOverIdList.contains(d.getId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return canUseSubjectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addItems(@NonNull String simulationId,
|
||||||
|
Map<SimulationWorkParamVO.Item, String> itemMap) {
|
||||||
|
if (!CollectionUtils.isEmpty(itemMap)) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
Simulation.Type simulationType = simulation.getType();
|
||||||
|
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(
|
||||||
|
simulationType);
|
||||||
// if (StringUtils.hasText(simulation.getCreatorId())) {
|
// if (StringUtils.hasText(simulation.getCreatorId())) {
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
|
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
|
||||||
// "非仿真创建者不能使用该功能");
|
// "非仿真创建者不能使用该功能");
|
||||||
// }
|
// }
|
||||||
initService.addItems(simulation, itemMap);
|
initService.addItems(simulation, itemMap);
|
||||||
SocketMessageVO<SimulationWorkParamVO> workParamMessage = SocketMessageFactory
|
SocketMessageVO<SimulationWorkParamVO> workParamMessage = SocketMessageFactory
|
||||||
.buildSimulationWorkParamMessage(simulationId, simulation.getBuildParams().getWorkParamVO());
|
.buildSimulationWorkParamMessage(simulationId,
|
||||||
Set<String> users = simulation.getSimulationUserIds();
|
simulation.getBuildParams().getWorkParamVO());
|
||||||
stompMessageService.sendToUser(users, workParamMessage);
|
Set<String> users = simulation.getSimulationUserIds();
|
||||||
}
|
stompMessageService.sendToUser(users, workParamMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeItems(@NonNull String simulationId, List<SimulationWorkParamVO.Item> items, LoginUserInfoVO loginInfo) {
|
public void removeItems(@NonNull String simulationId, List<SimulationWorkParamVO.Item> items,
|
||||||
if (!CollectionUtils.isEmpty(items)) {
|
LoginUserInfoVO loginInfo) {
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
if (!CollectionUtils.isEmpty(items)) {
|
||||||
Simulation.Type simulationType = simulation.getType();
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(simulationType);
|
Simulation.Type simulationType = simulation.getType();
|
||||||
|
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(
|
||||||
|
simulationType);
|
||||||
// if (StringUtils.hasText(simulation.getCreatorId())) {
|
// if (StringUtils.hasText(simulation.getCreatorId())) {
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
|
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
|
||||||
// "非仿真创建者不能使用该功能");
|
// "非仿真创建者不能使用该功能");
|
||||||
// }
|
// }
|
||||||
initService.removeFunctions(simulation, items);
|
initService.removeFunctions(simulation, items);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runAsPlan(String simulationId, RunAsPlanParam param) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(
|
||||||
|
simulation.getType());
|
||||||
|
initService.runAsPlan(simulation, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(String simulationId) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(
|
||||||
|
simulation.getType());
|
||||||
|
initService.reset(simulation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地图、功能ID获取仿真ID
|
||||||
|
*
|
||||||
|
* @param mapId 地图ID
|
||||||
|
* @param mapFunctionId 功能ID
|
||||||
|
* @return 仿真ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String querySimulationByMapIdAndMapFunction(long mapId, long mapFunctionId) {
|
||||||
|
return querySimulation(mapId, mapFunctionId).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地图、功能ID获取仿真信息获取实体
|
||||||
|
*/
|
||||||
|
public Simulation querySimulation(long mapId, long mapFunctionId) {
|
||||||
|
Simulation targetSimulation = simulationManager.getSimulationList().stream().filter(s -> {
|
||||||
|
Simulation simulation = (Simulation) s;
|
||||||
|
return simulation.getMapFunctionId() != null && simulation.getMapFunctionId() == mapFunctionId
|
||||||
|
&& simulation.getBuildParams().getMap().getId() == mapId;
|
||||||
|
}).findFirst().map(s -> (Simulation) s).orElse(null);
|
||||||
|
if (targetSimulation != null) {
|
||||||
|
return targetSimulation;
|
||||||
|
}
|
||||||
|
throw new SimulationException(SimulationExceptionType.Simulation_Not_Exist);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void monitor(String simulationId, AccountVO user) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
SimulationUser simulationUser = new SimulationUser(simulation, user,
|
||||||
|
club.joylink.rtss.simulation.SimulationUser.Type.TEACHER);
|
||||||
|
simulationWorkServiceManager.addSimulationUser(simulation, simulationUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Simulation createSimulation(long mapId, MapFunctionVO mapFunctionVO,
|
||||||
|
@NonNull SimulationWorkParamVO workParamVO,
|
||||||
|
@NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType) {
|
||||||
|
//获取仿真工作服务
|
||||||
|
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(
|
||||||
|
workParamVO.getType());
|
||||||
|
|
||||||
|
//创建仿真
|
||||||
|
String simulationId = SimulationIdGenerator.generateGroup(
|
||||||
|
loginUserInfoVO.getAccountVO().getId(), mapId);
|
||||||
|
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId);
|
||||||
|
|
||||||
|
//语音配置数据
|
||||||
|
List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId);
|
||||||
|
simulation.setVoiceRuleList(ruleList);
|
||||||
|
|
||||||
|
simulation.setMapFunctionVO(mapFunctionVO);
|
||||||
|
simulation.setCreateUserType(createUserType);
|
||||||
|
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
|
||||||
|
if (Objects.nonNull(loginUserInfo)) {
|
||||||
|
simulation.setCreatorId(loginUserInfo.getAccountVO().getIdStr());
|
||||||
|
simulation.setProject(loginUserInfo.getProject());
|
||||||
|
simulation.setProjectVO(loginUserInfo.getProjectInfo());
|
||||||
|
}
|
||||||
|
// 删除旧仿真,保存新仿真
|
||||||
|
simulation.setMessageSender(this.defaultMessageSender); // 设置默认的消息发布器
|
||||||
|
simulation.loadModule(); // 加载通用模块
|
||||||
|
groupSimulationService.clearSimulation(simulation.getId());
|
||||||
|
simulationManager.saveNew(simulation);
|
||||||
|
initService.loadData(simulation);
|
||||||
|
initService.addJobs(simulation);
|
||||||
|
initService.addMessagePublisher(simulation);
|
||||||
|
initService.init(simulation);
|
||||||
|
if (!CollectionUtils.isEmpty(workParamVO.getItemMap())) {
|
||||||
|
initService.addItems(simulation, workParamVO.getItemMap());
|
||||||
|
}
|
||||||
|
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
|
||||||
|
// 群组配置信息
|
||||||
|
simulation.initDefaultConversationGroupMap();
|
||||||
|
// 仿真开始运行
|
||||||
|
simulationManager.start(simulation.getId());
|
||||||
|
return simulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo,
|
||||||
|
boolean checkAuth) {
|
||||||
|
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
|
||||||
|
Long mapId = mapFunctionVO.getMapId();
|
||||||
|
Map<String, Boolean> createUserType = Maps.newHashMap();
|
||||||
|
if (checkAuth) {
|
||||||
|
createUserType = this.checkUserPermission(mapFunctionVO, loginInfo);
|
||||||
|
}
|
||||||
|
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();
|
||||||
|
|
||||||
|
if (workParamVO.containsRealDeviceItem()) {
|
||||||
|
//有实体设备加载项的地图功能(实训室)同时只能存在一个
|
||||||
|
Stream<Simulation> stream = simulationManager.getSimulationStream(Simulation.class);
|
||||||
|
Optional<Simulation> oldSimulationOptional = stream
|
||||||
|
.filter(sim -> Objects.equals(sim.getMapFunctionId(), mapFunctionId))
|
||||||
|
.findFirst();
|
||||||
|
oldSimulationOptional.ifPresent(simulation -> simulationManager.destroy(simulation.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
return createSimulation(mapId, mapFunctionVO, mapFunctionVO.getParamVO(), loginInfo,
|
||||||
public void runAsPlan(String simulationId, RunAsPlanParam param) {
|
createUserType);
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
}
|
||||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(simulation.getType());
|
|
||||||
initService.runAsPlan(simulation, param);
|
@Override
|
||||||
|
public void loadDraftRunPlan(String simulationId, long draftRunPlanId) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
if (simulation.isPlanRunning()) {
|
||||||
|
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed,
|
||||||
|
String.format("计划运行中,无法重新加载运行计划"));
|
||||||
}
|
}
|
||||||
|
RunPlanVO runPlanVO = runPlanDraftService.getById(draftRunPlanId);
|
||||||
|
// 重新加载运行计划匹配的派班计划
|
||||||
|
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlanVO, null);
|
||||||
|
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(String simulationId) {
|
public SimulationVO querySimulationJoinedByUser(long userId) {
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
Optional<club.joylink.rtss.simulation.Simulation> optional = simulationManager.getSimulationStream(
|
||||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(simulation.getType());
|
null)
|
||||||
initService.reset(simulation);
|
.filter(simulation -> simulation.querySimulationUserById(String.valueOf(userId)) != null)
|
||||||
|
.findFirst();
|
||||||
|
return optional.map(
|
||||||
|
simulation -> groupSimulationService.getSimulationBasicInfo(simulation.getId()))
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SimulationInfoVO> listSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO) {
|
||||||
|
Stream<Simulation> stream = this.simulationManager.getSimulationStream(Simulation.class);
|
||||||
|
stream = stream.filter(simulation -> Objects.equals(topOrgId,
|
||||||
|
simulation.getBuildParams().getLoginUserInfo().getTopOrgId()));
|
||||||
|
|
||||||
|
if (StringUtils.hasText(queryVO.getGroup())) {
|
||||||
|
stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
||||||
}
|
}
|
||||||
|
if (StringUtils.hasText(queryVO.getUserName())) {
|
||||||
/**
|
stream = stream.filter(simulation -> simulation.getSimulationUsers().stream()
|
||||||
* 根据地图、功能ID获取仿真ID
|
.anyMatch(user -> user.getName().contains(queryVO.getUserName())));
|
||||||
*
|
|
||||||
* @param mapId 地图ID
|
|
||||||
* @param mapFunctionId 功能ID
|
|
||||||
* @return 仿真ID
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String querySimulationByMapIdAndMapFunction(long mapId, long mapFunctionId) {
|
|
||||||
return querySimulation(mapId, mapFunctionId).getId();
|
|
||||||
}
|
}
|
||||||
|
return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 根据地图、功能ID获取仿真信息获取实体
|
public PageVO<SimulationInfoVO> pagedSimulationByOrg(Long topOrgId,
|
||||||
*/
|
SimulationInfoQueryVO queryVO) {
|
||||||
public Simulation querySimulation(long mapId, long mapFunctionId) {
|
List<SimulationInfoVO> list = listSimulationByOrg(topOrgId, queryVO);
|
||||||
Simulation targetSimulation = simulationManager.getSimulationList().stream().filter(s -> {
|
Stream<SimulationInfoVO> stream = list.stream();
|
||||||
Simulation simulation = (Simulation) s;
|
int skipNum = (queryVO.getPageNum() - 1) * queryVO.getPageSize();
|
||||||
return simulation.getMapFunctionId() != null && simulation.getMapFunctionId() == mapFunctionId
|
List<SimulationInfoVO> collect = stream.skip(skipNum).limit(queryVO.getPageSize())
|
||||||
&& simulation.getBuildParams().getMap().getId() == mapId;
|
.collect(Collectors.toList());
|
||||||
}).findFirst().map(s -> (Simulation) s).orElse(null);
|
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), list.size(), collect);
|
||||||
if (targetSimulation != null) {
|
}
|
||||||
return targetSimulation;
|
|
||||||
}
|
@Override
|
||||||
throw new SimulationException(SimulationExceptionType.Simulation_Not_Exist);
|
public void sendUnreceivedMessages(String simulationId, String memberId) {
|
||||||
|
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
||||||
|
SimulationMember member = simulation.getSimulationMemberById(memberId);
|
||||||
|
while (true) {
|
||||||
|
SocketMessageVO<?> message = member.getUnreceivedMessages().poll();
|
||||||
|
if (message == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
stompMessageService.sendToUser(member.getUserId(), message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void monitor(String simulationId, AccountVO user) {
|
public List<SimulationInfoVO> listAllSimulation(SimulationInfoQueryVO queryVO) {
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
List<Simulation> simulationList = this.simulationManager.getSimulationList();
|
||||||
SimulationUser simulationUser = new SimulationUser(simulation, user, club.joylink.rtss.simulation.SimulationUser.Type.TEACHER);
|
Stream<Simulation> stream = simulationList.stream();
|
||||||
simulationWorkServiceManager.addSimulationUser(simulation, simulationUser);
|
if (StringUtils.hasText(queryVO.getGroup())) {
|
||||||
|
stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
||||||
}
|
}
|
||||||
|
if (StringUtils.hasText(queryVO.getUserName())) {
|
||||||
private Simulation createSimulation(long mapId, MapFunctionVO mapFunctionVO, @NonNull SimulationWorkParamVO workParamVO,
|
stream = stream.filter(simulation -> simulation.getSimulationUsers().stream()
|
||||||
@NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType) {
|
.anyMatch(user -> user.getName().contains(queryVO.getUserName())));
|
||||||
//获取仿真工作服务
|
|
||||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
|
|
||||||
|
|
||||||
//创建仿真
|
|
||||||
String simulationId = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
|
|
||||||
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId);
|
|
||||||
|
|
||||||
//语音配置数据
|
|
||||||
List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId);
|
|
||||||
simulation.setVoiceRuleList(ruleList);
|
|
||||||
|
|
||||||
simulation.setMapFunctionVO(mapFunctionVO);
|
|
||||||
simulation.setCreateUserType(createUserType);
|
|
||||||
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
|
|
||||||
if (Objects.nonNull(loginUserInfo)) {
|
|
||||||
simulation.setCreatorId(loginUserInfo.getAccountVO().getIdStr());
|
|
||||||
simulation.setProject(loginUserInfo.getProject());
|
|
||||||
simulation.setProjectVO(loginUserInfo.getProjectInfo());
|
|
||||||
}
|
|
||||||
// 删除旧仿真,保存新仿真
|
|
||||||
simulation.setMessageSender(this.defaultMessageSender); // 设置默认的消息发布器
|
|
||||||
simulation.loadModule(); // 加载通用模块
|
|
||||||
groupSimulationService.clearSimulation(simulation.getId());
|
|
||||||
simulationManager.saveNew(simulation);
|
|
||||||
initService.loadData(simulation);
|
|
||||||
initService.addJobs(simulation);
|
|
||||||
initService.addMessagePublisher(simulation);
|
|
||||||
initService.init(simulation);
|
|
||||||
if (!CollectionUtils.isEmpty(workParamVO.getItemMap())) {
|
|
||||||
initService.addItems(simulation, workParamVO.getItemMap());
|
|
||||||
}
|
|
||||||
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
|
|
||||||
// 群组配置信息
|
|
||||||
simulation.initDefaultConversationGroupMap();
|
|
||||||
// 仿真开始运行
|
|
||||||
simulationManager.start(simulation.getId());
|
|
||||||
return simulation;
|
|
||||||
}
|
}
|
||||||
|
if (queryVO.getFunctionId() != null) {
|
||||||
@Override
|
stream = stream.filter(
|
||||||
public Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth) {
|
simulation -> Objects.equals(queryVO.getFunctionId(), simulation.getMapFunctionId()));
|
||||||
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
|
|
||||||
Long mapId = mapFunctionVO.getMapId();
|
|
||||||
Map<String, Boolean> createUserType = Maps.newHashMap();
|
|
||||||
if (checkAuth) {
|
|
||||||
createUserType = this.checkUserPermission(mapFunctionVO, loginInfo);
|
|
||||||
}
|
|
||||||
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();
|
|
||||||
|
|
||||||
if (workParamVO.containsRealDeviceItem()) {
|
|
||||||
//有实体设备加载项的地图功能(实训室)同时只能存在一个
|
|
||||||
Stream<Simulation> stream = simulationManager.getSimulationStream(Simulation.class);
|
|
||||||
Optional<Simulation> oldSimulationOptional = stream
|
|
||||||
.filter(sim -> Objects.equals(sim.getMapFunctionId(), mapFunctionId))
|
|
||||||
.findFirst();
|
|
||||||
oldSimulationOptional.ifPresent(simulation -> simulationManager.destroy(simulation.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return createSimulation(mapId, mapFunctionVO, mapFunctionVO.getParamVO(), loginInfo, createUserType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadDraftRunPlan(String simulationId, long draftRunPlanId) {
|
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
|
||||||
if (simulation.isPlanRunning()) {
|
|
||||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed,
|
|
||||||
String.format("计划运行中,无法重新加载运行计划"));
|
|
||||||
}
|
|
||||||
RunPlanVO runPlanVO = runPlanDraftService.getById(draftRunPlanId);
|
|
||||||
// 重新加载运行计划匹配的派班计划
|
|
||||||
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlanVO, null);
|
|
||||||
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SimulationVO querySimulationJoinedByUser(long userId) {
|
|
||||||
Optional<club.joylink.rtss.simulation.Simulation> optional = simulationManager.getSimulationStream(null)
|
|
||||||
.filter(simulation -> simulation.querySimulationUserById(String.valueOf(userId)) != null)
|
|
||||||
.findFirst();
|
|
||||||
return optional.map(simulation -> groupSimulationService.getSimulationBasicInfo(simulation.getId())).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SimulationInfoVO> listSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO) {
|
|
||||||
Stream<Simulation> stream = this.simulationManager.getSimulationStream(Simulation.class);
|
|
||||||
stream = stream.filter(simulation -> Objects.equals(topOrgId, simulation.getBuildParams().getLoginUserInfo().getTopOrgId()));
|
|
||||||
|
|
||||||
if (StringUtils.hasText(queryVO.getGroup())) {
|
|
||||||
stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
|
|
||||||
}
|
|
||||||
if (StringUtils.hasText(queryVO.getUserName())) {
|
|
||||||
stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> user.getName().contains(queryVO.getUserName())));
|
|
||||||
}
|
|
||||||
return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageVO<SimulationInfoVO> pagedSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO) {
|
|
||||||
List<SimulationInfoVO> list = listSimulationByOrg(topOrgId, queryVO);
|
|
||||||
Stream<SimulationInfoVO> stream = list.stream();
|
|
||||||
int skipNum = (queryVO.getPageNum() - 1) * queryVO.getPageSize();
|
|
||||||
List<SimulationInfoVO> collect = stream.skip(skipNum).limit(queryVO.getPageSize()).collect(Collectors.toList());
|
|
||||||
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), list.size(), collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendUnreceivedMessages(String simulationId, String memberId) {
|
|
||||||
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
|
|
||||||
SimulationMember member = simulation.getSimulationMemberById(memberId);
|
|
||||||
while (true) {
|
|
||||||
SocketMessageVO<?> message = member.getUnreceivedMessages().poll();
|
|
||||||
if (message == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
stompMessageService.sendToUser(member.getUserId(), message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return stream.map(Simulation::convertToVO).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.communication.vo;
|
|
||||||
//
|
|
||||||
//import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
|
||||||
//import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
|
||||||
//import lombok.Getter;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 站台屏蔽门开/关门控制消息
|
|
||||||
// */
|
|
||||||
//@Getter
|
|
||||||
//public class PsdSwitch extends ControllableDevice {
|
|
||||||
//
|
|
||||||
// /** true-开门 false-关门 */
|
|
||||||
// @JsonSerialize(using = Boolean2NumSerializer.class)
|
|
||||||
// private boolean open;
|
|
||||||
//
|
|
||||||
// public PsdSwitch(VirtualRealityScreenDoor psd, boolean open) {
|
|
||||||
// super(psd.getCode(), psd.getDeviceType());
|
|
||||||
// this.open = open;
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,25 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.communication.vo;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
|
||||||
//import lombok.Getter;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 信号机点灯状态
|
|
||||||
// */
|
|
||||||
//@Getter
|
|
||||||
//public class SignalLight extends ControllableDevice {
|
|
||||||
// /**
|
|
||||||
// * 信号显示
|
|
||||||
// */
|
|
||||||
// private SignalAspect aspect;
|
|
||||||
//
|
|
||||||
// public SignalLight(VirtualRealitySignal signal) {
|
|
||||||
// super(signal.getCode(), signal.getDeviceType());
|
|
||||||
// if (signal.getCommand() != null) {
|
|
||||||
// this.aspect = signal.getCommand();
|
|
||||||
// } else {
|
|
||||||
// this.aspect = signal.getAspect();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,22 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.communication.vo;
|
|
||||||
//
|
|
||||||
//import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
|
||||||
//import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
|
||||||
//import lombok.Getter;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 道岔开始转动消息
|
|
||||||
// */
|
|
||||||
//@Getter
|
|
||||||
//public class SwitchTurn extends ControllableDevice {
|
|
||||||
//
|
|
||||||
// /** true-转到定位 false-转到反位 */
|
|
||||||
// @JsonSerialize(using = Boolean2NumSerializer.class)
|
|
||||||
// private boolean normal;
|
|
||||||
//
|
|
||||||
// public SwitchTurn(VirtualRealitySwitch vrSwitch, boolean normal) {
|
|
||||||
// super(vrSwitch.getCode(), vrSwitch.getDeviceType());
|
|
||||||
// this.normal = normal;
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,22 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.data.support;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
|
||||||
//import lombok.Getter;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 列车停稳消息
|
|
||||||
// */
|
|
||||||
//@Getter
|
|
||||||
//public class TrainStopMessage {
|
|
||||||
//
|
|
||||||
// private VirtualRealityTrain train;
|
|
||||||
//
|
|
||||||
// private Section section;
|
|
||||||
//
|
|
||||||
// public TrainStopMessage(VirtualRealityTrain train) {
|
|
||||||
// this.train = train;
|
|
||||||
// this.section = train.getHeadPosition().getSection();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,44 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.PlcGateway;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig;
|
|
||||||
//import club.joylink.rtss.vo.client.project.cgy.CgySectionConfigVO;
|
|
||||||
//import club.joylink.rtss.vo.client.project.say.SaySectionConfigVO;
|
|
||||||
//import io.netty.buffer.ByteBuf;
|
|
||||||
//import org.springframework.stereotype.Service;
|
|
||||||
//
|
|
||||||
//@Service
|
|
||||||
//public class CgySectionServiceImpl implements RealDeviceService {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean canHandle(RealDeviceConfig deviceConfig) {
|
|
||||||
// return deviceConfig instanceof CgySectionConfig;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
|
||||||
// PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
|
||||||
// if (plcGateway == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// CgySectionConfig config = (CgySectionConfig) deviceConfig;
|
|
||||||
// VirtualRealitySectionAxleCounter vrAxleCounter = (VirtualRealitySectionAxleCounter) config.getMapElement();
|
|
||||||
// if (vrAxleCounter == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// CgySectionConfigVO configVO = config.getConfigVO();
|
|
||||||
// ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(),
|
|
||||||
// configVO.getQuantity());
|
|
||||||
//
|
|
||||||
// boolean r_clear = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_clear());
|
|
||||||
// vrAxleCounter.setOccupy(!r_clear);
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,356 +0,0 @@
|
||||||
//package club.joylink.rtss.simulation.cbtc.passenger.strategy.service;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.passenger.strategy.Config;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.*;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.time.LocalDateTime;
|
|
||||||
//import java.time.LocalTime;
|
|
||||||
//import java.util.*;
|
|
||||||
//
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class JumpAndParkTimeStrategyServiceImpl implements StrategyService<JumpAndParkTimeStrategy> {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<JumpAndParkTimeStrategy> generateStrategy(StrategyCalculateData data) {
|
|
||||||
// List<JumpAndParkTimeStrategy> list = new ArrayList<>();
|
|
||||||
// List<StandPassenger> lpfList = data.queryLpfList();
|
|
||||||
// if (CollectionUtils.isEmpty(lpfList)) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// // 暂时按一个站大客流处理
|
|
||||||
// StandPassenger standPassenger = lpfList.get(0);
|
|
||||||
// Stand stand = standPassenger.getStand();
|
|
||||||
// Map<String, List<TripPlan>> planMap = data.getPlanMap();
|
|
||||||
// int planParkTime = 0; // 计划停站时间
|
|
||||||
// for (List<TripPlan> planList : planMap.values()) {
|
|
||||||
// for (TripPlan tripPlan : planList) {
|
|
||||||
// List<StationPlan> stationPlanList = tripPlan.getPlanList();
|
|
||||||
// for (StationPlan stationPlan : stationPlanList) {
|
|
||||||
// if (Objects.equals(stationPlan.getSection(), stand.getSection()) &&
|
|
||||||
// stationPlan.getParkTime() > 0) {
|
|
||||||
// planParkTime = stationPlan.getParkTime();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (planParkTime > 0) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (planParkTime <= 0) {
|
|
||||||
// throw new IllegalArgumentException(String.format("计划或站台[%s]数据异常,找到的计划停站时间异常:为[%s]", stand.debugStr(), planParkTime));
|
|
||||||
// }
|
|
||||||
// // 最大停站时间内每隔5秒生成一个策略(策略的停站时间为计划停站时间+5*i)
|
|
||||||
// int iter = (Config.STAND_MAX_STOP_TIME - planParkTime) / 5;
|
|
||||||
// for (int i = 1; i <= iter; i++) {
|
|
||||||
// list.add(new JumpAndParkTimeStrategy(stand, planParkTime + i * 5));
|
|
||||||
// }
|
|
||||||
// List<Stand> leftStandList = data.getLeftStandList();
|
|
||||||
// List<Stand> rightStandList = data.getRightStandList();
|
|
||||||
// boolean right = false;
|
|
||||||
// int index = leftStandList.indexOf(stand);
|
|
||||||
// if (index < 0) {
|
|
||||||
// // 不是左向站台
|
|
||||||
// right = true;
|
|
||||||
// index = rightStandList.indexOf(stand);
|
|
||||||
// }
|
|
||||||
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(index >= 0, String.format("未找到站台[%s]", stand.debugStr()));
|
|
||||||
// log.debug(String.format("[%s]第[%s]个站台大客流", right?"右向":"左向", (index+1)));
|
|
||||||
//
|
|
||||||
// boolean hasJump = false;
|
|
||||||
// if (index == 0) {
|
|
||||||
// // 第一站,不生成跳停策略
|
|
||||||
// log.debug(String.format("第一个站,不生成跳停策略"));
|
|
||||||
// }
|
|
||||||
// List<Stand> jumpableStandList;
|
|
||||||
// if (right) {
|
|
||||||
// jumpableStandList = rightStandList.subList(0, index);
|
|
||||||
// } else {
|
|
||||||
// jumpableStandList = leftStandList.subList(0, index);
|
|
||||||
// }
|
|
||||||
// List<TrainPassenger> trainPassengerList = data.getTrainPassengerList();
|
|
||||||
// for (int i = jumpableStandList.size()-1; i > 0; i--) { // 起始站不跳停
|
|
||||||
// Stand s = jumpableStandList.get(i);
|
|
||||||
// // 该站台人数是否支持跳停
|
|
||||||
// StandPassenger sp = data.getStandPassengerByStand(s);
|
|
||||||
// if (sp.getWait() >= Config.STAND_JUMP_MAX) {
|
|
||||||
// log.debug(String.format("站台[%s]客流数[%s]>=站台跳停最大客流量[%s],不能跳停",
|
|
||||||
// s.debugStr(), sp.getWait(), Config.STAND_JUMP_MAX));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // 该站是否被前列车跳过
|
|
||||||
// RealRun jumpRun = this.isJustJumped(data, s);
|
|
||||||
// if (jumpRun != null) {
|
|
||||||
// log.debug(String.format("站台[%s]刚被跳停,不生成", s.debugStr()));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // 前一站是否刚跳停
|
|
||||||
// if (i - 1 > 0) {
|
|
||||||
// Stand pre = jumpableStandList.get(i - 1);
|
|
||||||
// jumpRun = this.isJustJumped(data, pre);
|
|
||||||
// if (jumpRun != null) {
|
|
||||||
// boolean jump = false;
|
|
||||||
// List<RealRun> realRuns = data.queryRealRuns(jumpRun.getGroupNumber());
|
|
||||||
// int i1 = realRuns.indexOf(jumpRun);
|
|
||||||
// for (int j = i1; j < realRuns.size(); j++) {
|
|
||||||
// RealRun realRun = realRuns.get(j);
|
|
||||||
// if (Objects.equals(realRun.getSectionCode(), s.getSection().getCode())) {
|
|
||||||
// if (!realRun.isArrive()) {
|
|
||||||
// jump = true;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (jump) {
|
|
||||||
// log.debug(String.format("站台[%s]的前一站台[%s]刚被跳停,不生成", s.debugStr(), pre.debugStr()));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// hasJump = true;
|
|
||||||
// for (JumpAndParkTimeStrategy jumpAndParkTimeStrategy : list) {
|
|
||||||
// jumpAndParkTimeStrategy.setJumpStand(s);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!hasJump) {
|
|
||||||
// list.clear();
|
|
||||||
// }
|
|
||||||
// log.debug(String.format("生成跳停+停站时间策略[%s]个", list.size()));
|
|
||||||
// return list;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private RealRun isJustJumped(StrategyCalculateData data, Stand stand) {
|
|
||||||
// List<TrainPassenger> trainPassengerList = data.getTrainPassengerList();
|
|
||||||
// StationPlan plan = null;
|
|
||||||
// boolean jump = false;
|
|
||||||
// RealRun standLastRun = null;
|
|
||||||
// for (TrainPassenger trainPassenger : trainPassengerList) {
|
|
||||||
// String groupNumber = trainPassenger.getGroupNumber();
|
|
||||||
// TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber());
|
|
||||||
// if (tripPlan == null) {
|
|
||||||
// log.warn(String.format("列车[%s-%s|%s]没有找到车次计划",
|
|
||||||
// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// int index = tripPlan.getPlanIndex(stand.getSection());
|
|
||||||
// if (index < 0) { // 没有对应站台计划,无需判断跳停
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// List<RealRun> realRunList = data.queryRealRuns(groupNumber);
|
|
||||||
// if (!CollectionUtils.isEmpty(realRunList)) {
|
|
||||||
// realRunList.sort(Comparator.comparing(RealRun::getTime));
|
|
||||||
// RealRun last = realRunList.get(realRunList.size() - 1);
|
|
||||||
// int lastRunIndex = tripPlan.getPlanIndex(last.getSectionCode());
|
|
||||||
// if (lastRunIndex < index) { // 列车实际运行未过站台
|
|
||||||
// StationPlan stationPlan = tripPlan.getPlanList().get(index);
|
|
||||||
// if (plan == null || plan.getArriveTime().isAfter(stationPlan.getArriveTime())) {
|
|
||||||
// plan = stationPlan;
|
|
||||||
// }
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// for (int i = realRunList.size() - 1; i >= 0; i--) {
|
|
||||||
// RealRun realRun = realRunList.get(i);
|
|
||||||
// if (!Objects.equals(realRun.getServiceNumber(), trainPassenger.getServiceNumber()) ||
|
|
||||||
// !Objects.equals(realRun.getTripNumber(), trainPassenger.getTripNumber())) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if (Objects.equals(realRun.getSectionCode(), stand.getSection().getCode())) {
|
|
||||||
// if (!realRun.isArrive() && i > 0) {
|
|
||||||
// RealRun pre = realRunList.get(i - 1);
|
|
||||||
// if (pre.isArrive() &&
|
|
||||||
// Objects.equals(pre.getSectionCode(), stand.getSection().getCode())) {
|
|
||||||
// if (standLastRun == null || standLastRun.getTime().isAfter(pre.getTime())) {
|
|
||||||
// jump = false;
|
|
||||||
// standLastRun = pre;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (standLastRun == null || standLastRun.getTime().isAfter(realRun.getTime())) {
|
|
||||||
// jump = true;
|
|
||||||
// standLastRun = realRun;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (jump) {
|
|
||||||
// return standLastRun;
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void calculate(StrategyCalculateData data, JumpAndParkTimeStrategy strategy) {
|
|
||||||
// List<TrainPassenger> trainPassengerList = data.getTrainPassengerList();
|
|
||||||
// LocalDateTime systemTime = data.getSystemTime();
|
|
||||||
// LocalDateTime startTime = systemTime;
|
|
||||||
// LocalDateTime endTime = systemTime.plusMinutes(Config.STRATEGY_CAL_TIME);
|
|
||||||
// boolean jump = false;
|
|
||||||
// int i = 0;
|
|
||||||
// while (startTime.isBefore(endTime) && i < 1000) {
|
|
||||||
// ++i;
|
|
||||||
// LocalDateTime nextTime = null;
|
|
||||||
// for (TrainPassenger trainPassenger : trainPassengerList) {
|
|
||||||
// String groupNumber = trainPassenger.getGroupNumber();
|
|
||||||
// List<RealRun> realRunList = data.queryRealRuns(groupNumber);
|
|
||||||
// if (CollectionUtils.isEmpty(realRunList)) {
|
|
||||||
// TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber());
|
|
||||||
// if (tripPlan == null) {
|
|
||||||
// log.warn(String.format("列车[%s-%s|%s]没有找到车次计划",
|
|
||||||
// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (tripPlan.isBackup()) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// List<StationPlan> planList = tripPlan.getPlanList();
|
|
||||||
// for (StationPlan stationPlan : planList) {
|
|
||||||
// if (stationPlan.getArriveTime().compareTo(systemTime.toLocalTime()) >= 0) {
|
|
||||||
// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, stationPlan);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// realRunList = data.queryRealRuns(groupNumber);
|
|
||||||
// if (CollectionUtils.isEmpty(realRunList)) {
|
|
||||||
// log.error(String.format("列车[%s-%s|%s],车次[%s],时间[%s]",
|
|
||||||
// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber(),
|
|
||||||
// tripPlan.debugStr(), systemTime.toString()));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// RealRun lastRun = realRunList.get(realRunList.size() - 1);
|
|
||||||
// TripPlan tripPlan = data.queryTripPlan(lastRun.getServiceNumber(), lastRun.getTripNumber());
|
|
||||||
// StationPlan stationPlan = tripPlan.queryStationPlanByStationCode(lastRun.getStationCode());
|
|
||||||
// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(stationPlan);
|
|
||||||
// if (lastRun.isArrive()) {
|
|
||||||
// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, stationPlan);
|
|
||||||
// } else {
|
|
||||||
// if (tripPlan.isLastPlan(stationPlan)) {
|
|
||||||
// TripPlan nextTripPlan = data.queryNextTripPlan(tripPlan);
|
|
||||||
// if (nextTripPlan != null) {
|
|
||||||
// StationPlan nextStationPlan = nextTripPlan.getFirstStationPlan();
|
|
||||||
// this.handleTrainRun(data, strategy, trainPassenger, nextTripPlan, nextStationPlan);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// StationPlan nextStationPlan = tripPlan.queryNextStationPlan(stationPlan.getStation());
|
|
||||||
// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, nextStationPlan);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 更新nextTime
|
|
||||||
// if (!CollectionUtils.isEmpty(realRunList)) {
|
|
||||||
// RealRun last = realRunList.get(realRunList.size() - 1);
|
|
||||||
// if (nextTime == null || nextTime.isAfter(last.getTime())) {
|
|
||||||
// nextTime = last.getTime();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// systemTime = nextTime;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void handleTrainRun(StrategyCalculateData data,
|
|
||||||
// JumpAndParkTimeStrategy strategy,
|
|
||||||
// TrainPassenger trainPassenger,
|
|
||||||
// TripPlan tripPlan, StationPlan stationPlan) {
|
|
||||||
// Stand stand = strategy.getJumpStand();
|
|
||||||
// String groupNumber = trainPassenger.getGroupNumber();
|
|
||||||
// List<RealRun> realRunList = data.queryRealRuns(groupNumber);
|
|
||||||
// RealRun lastRun = null;
|
|
||||||
// int offset = 0;
|
|
||||||
// if (!CollectionUtils.isEmpty(realRunList)) {
|
|
||||||
// // 获取上一个实际运行,并计算时间偏移
|
|
||||||
// lastRun = realRunList.get(realRunList.size() - 1);
|
|
||||||
// TripPlan lastTripPlan = data.queryTripPlan(lastRun.getServiceNumber(), lastRun.getTripNumber());
|
|
||||||
// StationPlan lastStationPlan = lastTripPlan.queryStationPlanByStationCode(lastRun.getStationCode());
|
|
||||||
// if (lastRun.isArrive()) {
|
|
||||||
// offset = lastRun.getTime().toLocalTime().toSecondOfDay() - lastStationPlan.getArriveTime().toSecondOfDay();
|
|
||||||
// } else {
|
|
||||||
// offset = lastRun.getTime().toLocalTime().toSecondOfDay() - lastStationPlan.getLeaveTime().toSecondOfDay();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (Objects.equals(stand.getSection(), stationPlan.getSection()) && !strategy.isJumped()) { // 跳停站台计划
|
|
||||||
// // 跳停策略指定的跳停站台,构建跳停运行,并更新策略
|
|
||||||
// RealRun passing = this.buildRealRun(groupNumber, tripPlan, stationPlan, false,
|
|
||||||
// stationPlan.getArriveTime(), offset, data.getSystemTime());
|
|
||||||
// data.addRealRun(passing);
|
|
||||||
// strategy.jumpedByTrain(groupNumber, tripPlan);
|
|
||||||
// strategy.addOffset(-Config.TRAIN_PASS_SAVE_TIME);
|
|
||||||
// StandPassenger standPassenger = data.getStandPassengerByStand(stand);
|
|
||||||
// strategy.addEffectTrain(groupNumber);
|
|
||||||
// strategy.addExtraNum(standPassenger.getWait());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// // 非跳停,根据计划更新预测运行
|
|
||||||
// if (lastRun == null ||
|
|
||||||
// !Objects.equals(stationPlan.getStation().getCode(), lastRun.getStationCode())) {
|
|
||||||
// RealRun arrive = this.buildRealRun(groupNumber, tripPlan, stationPlan, true,
|
|
||||||
// stationPlan.getArriveTime(), offset, data.getSystemTime());
|
|
||||||
// data.addRealRun(arrive);
|
|
||||||
// }
|
|
||||||
// int parkTime = stationPlan.getParkTime();
|
|
||||||
// // 列车到站乘客上车,更新列车上人数
|
|
||||||
// if (stationPlan.getSection().getStandList().size() == 0) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// Stand parkStand = strategy.getParkStand();
|
|
||||||
// LocalTime arriveTime = stationPlan.getArriveTime();
|
|
||||||
// LocalTime leaveTime = stationPlan.getLeaveTime();
|
|
||||||
// // 列车到站乘客上车,更新列车上人数
|
|
||||||
// StandPassenger standPassenger = data.getStandPassengerByStand(stationPlan.getSection().getStandList().get(0));
|
|
||||||
// int wait = standPassenger.getWait(); // 站台等待乘客数
|
|
||||||
// int normal = (parkTime - Config.INVALID_BOARD_TIME) * Config.PASSENGER_BOARD_SPEED; // 根据停站预测的可上车人数
|
|
||||||
// int remain = Config.TRAIN_CAPACITY - trainPassenger.getNum(); // 列车上剩余可载人数
|
|
||||||
// // 大客流站计算指标
|
|
||||||
// if (Objects.equals(stationPlan.getSection(), parkStand.getSection())) {
|
|
||||||
// // 时刻表偏差
|
|
||||||
// parkTime = strategy.getTime();
|
|
||||||
// leaveTime = arriveTime.plusSeconds(parkTime);
|
|
||||||
//// strategy.addTarget1(parkTime - stationPlan.getParkTime());
|
|
||||||
//// // 乘客等待时间(按人数统计,不考虑时间)
|
|
||||||
//// strategy.addTarget2(standPassenger.getWait());
|
|
||||||
// //
|
|
||||||
// strategy.addEffectTrain(groupNumber);
|
|
||||||
// int extraTime = strategy.getTime() - stationPlan.getParkTime();
|
|
||||||
// strategy.addOffset(extraTime);
|
|
||||||
// int extraNum = extraTime * Config.PASSENGER_BOARD_SPEED;
|
|
||||||
// int extra = extraNum;
|
|
||||||
// if (normal + extraNum > remain) {
|
|
||||||
// if (normal < remain) {
|
|
||||||
// extra = remain - normal;
|
|
||||||
// } else {
|
|
||||||
// extra = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// strategy.addExtraNum(extra);
|
|
||||||
// normal += extraNum;
|
|
||||||
// }
|
|
||||||
// float min = Math.min(Math.min(wait, normal), remain); // 实际上车人数
|
|
||||||
// standPassenger.minus(min);
|
|
||||||
// trainPassenger.plus(min);
|
|
||||||
//// // 大客流站计算指标
|
|
||||||
//// if (data.isLpfStand(stationPlan.getSection())) {
|
|
||||||
//// // 乘客等待时间(按人数统计,不考虑时间)
|
|
||||||
//// strategy.addTarget2(standPassenger.getWait());
|
|
||||||
//// }
|
|
||||||
// // 生成预测实际运行图
|
|
||||||
// RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false,
|
|
||||||
// leaveTime, offset, data.getSystemTime());
|
|
||||||
// data.addRealRun(leave);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String getName() {
|
|
||||||
// return "跳停策略服务";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package club.joylink.rtss.vo.client.cgy;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CgyThirdPartyLoginInfoVO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "appId不能为空")
|
||||||
|
private String appId;
|
||||||
|
private String sessionId;
|
||||||
|
private Long timeStamp;
|
||||||
|
@NotEmpty(message = "账号不能为空")
|
||||||
|
private String account;
|
||||||
|
@NotEmpty(message = "用户名不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String parentAccount;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package club.joylink.rtss.vo.client.simulationUsage;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SimulationUsageRecordQueryVO {
|
||||||
|
|
||||||
|
private Long uid;
|
||||||
|
private Long functionId;
|
||||||
|
}
|
|
@ -9,9 +9,12 @@ import lombok.Setter;
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class SimulationInfoQueryVO extends PageQueryVO {
|
public class SimulationInfoQueryVO extends PageQueryVO {
|
||||||
private String project;
|
|
||||||
|
|
||||||
private String group;
|
private String project;
|
||||||
|
|
||||||
private String userName;
|
private String group;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private Long functionId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
package club.joylink.rtss.vo.permission;
|
|
||||||
|
|
||||||
import club.joylink.rtss.vo.permission.subject.PermissionSubjectVO;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PermissionRefParamVO {
|
|
||||||
private Long distributeId;
|
|
||||||
private Long permissionId;
|
|
||||||
|
|
||||||
public static List<PermissionRefParamVO> convert(List<PermissionSubjectVO> vo){
|
|
||||||
List<PermissionRefParamVO> list = Lists.newArrayList();
|
|
||||||
for (PermissionSubjectVO subjectVO : vo) {
|
|
||||||
list.add(new PermissionRefParamVO(subjectVO.getDistributeId(),subjectVO.getPermissionId()));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -0,0 +1,204 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="club.joylink.rtss.dao.CgyViewDAO">
|
||||||
|
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.CgyView">
|
||||||
|
<id column="app_id" jdbcType="VARCHAR" property="appId" />
|
||||||
|
<result column="app_secret" jdbcType="VARCHAR" property="appSecret" />
|
||||||
|
<result column="function_id" jdbcType="BIGINT" property="functionId" />
|
||||||
|
<result column="view_count" jdbcType="BIGINT" property="viewCount" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Example_Where_Clause">
|
||||||
|
<where>
|
||||||
|
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||||
|
<if test="criteria.valid">
|
||||||
|
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||||
|
<foreach collection="criteria.criteria" item="criterion">
|
||||||
|
<choose>
|
||||||
|
<when test="criterion.noValue">
|
||||||
|
and ${criterion.condition}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.singleValue">
|
||||||
|
and ${criterion.condition} #{criterion.value}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.betweenValue">
|
||||||
|
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.listValue">
|
||||||
|
and ${criterion.condition}
|
||||||
|
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||||
|
#{listItem}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
<sql id="Update_By_Example_Where_Clause">
|
||||||
|
<where>
|
||||||
|
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||||
|
<if test="criteria.valid">
|
||||||
|
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||||
|
<foreach collection="criteria.criteria" item="criterion">
|
||||||
|
<choose>
|
||||||
|
<when test="criterion.noValue">
|
||||||
|
and ${criterion.condition}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.singleValue">
|
||||||
|
and ${criterion.condition} #{criterion.value}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.betweenValue">
|
||||||
|
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||||
|
</when>
|
||||||
|
<when test="criterion.listValue">
|
||||||
|
and ${criterion.condition}
|
||||||
|
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||||
|
#{listItem}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
app_id, app_secret, function_id, view_count
|
||||||
|
</sql>
|
||||||
|
<select id="selectByExample" parameterType="club.joylink.rtss.entity.CgyViewExample" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<if test="distinct">
|
||||||
|
distinct
|
||||||
|
</if>
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from cgy_view
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
<if test="orderByClause != null">
|
||||||
|
order by ${orderByClause}
|
||||||
|
</if>
|
||||||
|
<if test="limit != null">
|
||||||
|
<if test="offset != null">
|
||||||
|
limit ${offset}, ${limit}
|
||||||
|
</if>
|
||||||
|
<if test="offset == null">
|
||||||
|
limit ${limit}
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from cgy_view
|
||||||
|
where app_id = #{appId,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||||
|
delete from cgy_view
|
||||||
|
where app_id = #{appId,jdbcType=VARCHAR}
|
||||||
|
</delete>
|
||||||
|
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.CgyViewExample">
|
||||||
|
delete from cgy_view
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" parameterType="club.joylink.rtss.entity.CgyView">
|
||||||
|
insert into cgy_view (app_id, app_secret, function_id,
|
||||||
|
view_count)
|
||||||
|
values (#{appId,jdbcType=VARCHAR}, #{appSecret,jdbcType=VARCHAR}, #{functionId,jdbcType=BIGINT},
|
||||||
|
#{viewCount,jdbcType=BIGINT})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.CgyView">
|
||||||
|
insert into cgy_view
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="appId != null">
|
||||||
|
app_id,
|
||||||
|
</if>
|
||||||
|
<if test="appSecret != null">
|
||||||
|
app_secret,
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
function_id,
|
||||||
|
</if>
|
||||||
|
<if test="viewCount != null">
|
||||||
|
view_count,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="appId != null">
|
||||||
|
#{appId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="appSecret != null">
|
||||||
|
#{appSecret,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
#{functionId,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="viewCount != null">
|
||||||
|
#{viewCount,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<select id="countByExample" parameterType="club.joylink.rtss.entity.CgyViewExample" resultType="java.lang.Long">
|
||||||
|
select count(*) from cgy_view
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<update id="updateByExampleSelective" parameterType="map">
|
||||||
|
update cgy_view
|
||||||
|
<set>
|
||||||
|
<if test="record.appId != null">
|
||||||
|
app_id = #{record.appId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="record.appSecret != null">
|
||||||
|
app_secret = #{record.appSecret,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="record.functionId != null">
|
||||||
|
function_id = #{record.functionId,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="record.viewCount != null">
|
||||||
|
view_count = #{record.viewCount,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
|
<update id="updateByExample" parameterType="map">
|
||||||
|
update cgy_view
|
||||||
|
set app_id = #{record.appId,jdbcType=VARCHAR},
|
||||||
|
app_secret = #{record.appSecret,jdbcType=VARCHAR},
|
||||||
|
function_id = #{record.functionId,jdbcType=BIGINT},
|
||||||
|
view_count = #{record.viewCount,jdbcType=BIGINT}
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.CgyView">
|
||||||
|
update cgy_view
|
||||||
|
<set>
|
||||||
|
<if test="appSecret != null">
|
||||||
|
app_secret = #{appSecret,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
function_id = #{functionId,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="viewCount != null">
|
||||||
|
view_count = #{viewCount,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where app_id = #{appId,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.CgyView">
|
||||||
|
update cgy_view
|
||||||
|
set app_secret = #{appSecret,jdbcType=VARCHAR},
|
||||||
|
function_id = #{functionId,jdbcType=BIGINT},
|
||||||
|
view_count = #{viewCount,jdbcType=BIGINT}
|
||||||
|
where app_id = #{appId,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue