系统账号表增加source(账号来源)字段;为成工业增加统计相关接口;增加众合-陕铁院项目

This commit is contained in:
joylink_zhangsai 2022-06-20 18:01:03 +08:00
parent 635cc04815
commit eedf7198e2
28 changed files with 576 additions and 95 deletions

2
sql/20220617-thesai.sql Normal file
View File

@ -0,0 +1,2 @@
ALTER TABLE `sys_account`
ADD COLUMN `source` varchar(32) NULL COMMENT '账号来源' AFTER `roles`;

View File

@ -52,6 +52,8 @@ public enum Project {
TEST,
/** 中航-云南红河财经IBP盘项目 */
RICHOR_HHCJ,
/** 众合-陕铁院 */
UNITTEC_STY;
;
public static boolean isDefault(Project project) {

View File

@ -8,9 +8,9 @@ import club.joylink.rtss.services.training.ITrainingV1Service;
import club.joylink.rtss.services.training.data.GenerateConfig;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.UserTrainingListVO;
import club.joylink.rtss.vo.client.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.UserTrainingVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingListVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingVO;
import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.vo.client.training.TrainingQueryVO;
import club.joylink.rtss.vo.client.training.TrainingResultVO;

View File

@ -7,6 +7,8 @@ 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.user.AccountCreateVO;
import club.joylink.rtss.vo.client.user.AccountRegisterQueryVO;
import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
import club.joylink.rtss.vo.user.UserRegisterCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -134,4 +136,12 @@ public class UserInfoController {
this.iSysUserService.updatePassword(id, updatePasswordVO);
}
/**
* 统计注册人数
*/
@GetMapping("/statistic/count/registration")
public AccountRegisterStatisticsVO statisticRegisterCount(AccountRegisterQueryVO queryVO) {
return iSysUserService.statisticRegisterCount(queryVO);
}
}

View File

@ -6,6 +6,7 @@ import club.joylink.rtss.services.IUserUsageStatsService;
import club.joylink.rtss.services.user.IUserSimulationStatService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.simulationUsage.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -159,4 +160,21 @@ public class UserUsageStatsController {
iUserSimulationStatService.deleteUserSimulationStats(statsId, user);
}
/**
* 统计仿真使用时长分行调和现地
*/
@GetMapping("/statistic/simulationUsage")
public SimulationUsageStatisticsVO statisticSimulationUsage(String accountSource) {
return iUserSimulationStatService.statisticSimulationUsage(accountSource);
}
/**
* 统计实训使用时长
*/
@GetMapping("/statistic/trainingUsage")
public String statisticTrainingUsage(String accountSource) {
long duration = iUserUsageStatsService.statisticTrainingUsageDuration(accountSource);
return String.valueOf(duration);
}
}

View File

@ -4,8 +4,8 @@ import com.github.pagehelper.Page;
import club.joylink.rtss.entity.Training;
import club.joylink.rtss.entity.TrainingExample;
import club.joylink.rtss.entity.TrainingWithBLOBs;
import club.joylink.rtss.vo.client.UserTrainingListVO;
import club.joylink.rtss.vo.client.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingListVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingQueryVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

View File

@ -3,8 +3,8 @@ package club.joylink.rtss.dao;
import club.joylink.rtss.entity.UserSimulationStats;
import club.joylink.rtss.entity.UserSimulationStatsExample;
import club.joylink.rtss.vo.client.UserRankStatsVO;
import club.joylink.rtss.vo.client.UserSimulationStatsListVO;
import club.joylink.rtss.vo.client.UserSimulationStatsQueryVO;
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsListVO;
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsQueryVO;
import club.joylink.rtss.vo.client.org.StudentsUsageStatisticsVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

View File

@ -1,7 +1,5 @@
package club.joylink.rtss.entity;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -9,7 +7,6 @@ import java.time.LocalDateTime;
* @author
* 用户
*/
@Data
public class SysAccount implements Serializable {
private Long id;
@ -93,6 +90,11 @@ public class SysAccount implements Serializable {
*/
private String roles;
/**
* 账号来源
*/
private String source;
/**
* 创建时间
*/
@ -109,4 +111,267 @@ public class SysAccount implements Serializable {
private LocalDateTime updateTime;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getParentAccount() {
return parentAccount;
}
public void setParentAccount(String parentAccount) {
this.parentAccount = parentAccount;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getAvatarPath() {
return avatarPath;
}
public void setAvatarPath(String avatarPath) {
this.avatarPath = avatarPath;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getNationcode() {
return nationcode;
}
public void setNationcode(String nationcode) {
this.nationcode = nationcode;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public String getWxUnionId() {
return wxUnionId;
}
public void setWxUnionId(String wxUnionId) {
this.wxUnionId = wxUnionId;
}
public String getWmOpenId() {
return wmOpenId;
}
public void setWmOpenId(String wmOpenId) {
this.wmOpenId = wmOpenId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRoles() {
return roles;
}
public void setRoles(String roles) {
this.roles = roles;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public Long getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
SysAccount other = (SysAccount) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getAccount() == null ? other.getAccount() == null : this.getAccount().equals(other.getAccount()))
&& (this.getParentAccount() == null ? other.getParentAccount() == null : this.getParentAccount().equals(other.getParentAccount()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
&& (this.getAvatarPath() == null ? other.getAvatarPath() == null : this.getAvatarPath().equals(other.getAvatarPath()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
&& (this.getNationcode() == null ? other.getNationcode() == null : this.getNationcode().equals(other.getNationcode()))
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
&& (this.getWxId() == null ? other.getWxId() == null : this.getWxId().equals(other.getWxId()))
&& (this.getWxUnionId() == null ? other.getWxUnionId() == null : this.getWxUnionId().equals(other.getWxUnionId()))
&& (this.getWmOpenId() == null ? other.getWmOpenId() == null : this.getWmOpenId().equals(other.getWmOpenId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getRoles() == null ? other.getRoles() == null : this.getRoles().equals(other.getRoles()))
&& (this.getSource() == null ? other.getSource() == null : this.getSource().equals(other.getSource()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateUserId() == null ? other.getUpdateUserId() == null : this.getUpdateUserId().equals(other.getUpdateUserId()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getAccount() == null) ? 0 : getAccount().hashCode());
result = prime * result + ((getParentAccount() == null) ? 0 : getParentAccount().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
result = prime * result + ((getAvatarPath() == null) ? 0 : getAvatarPath().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
result = prime * result + ((getNationcode() == null) ? 0 : getNationcode().hashCode());
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
result = prime * result + ((getWxId() == null) ? 0 : getWxId().hashCode());
result = prime * result + ((getWxUnionId() == null) ? 0 : getWxUnionId().hashCode());
result = prime * result + ((getWmOpenId() == null) ? 0 : getWmOpenId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getRoles() == null) ? 0 : getRoles().hashCode());
result = prime * result + ((getSource() == null) ? 0 : getSource().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateUserId() == null) ? 0 : getUpdateUserId().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", account=").append(account);
sb.append(", parentAccount=").append(parentAccount);
sb.append(", type=").append(type);
sb.append(", orgId=").append(orgId);
sb.append(", name=").append(name);
sb.append(", nickname=").append(nickname);
sb.append(", avatarPath=").append(avatarPath);
sb.append(", password=").append(password);
sb.append(", mobile=").append(mobile);
sb.append(", nationcode=").append(nationcode);
sb.append(", email=").append(email);
sb.append(", wxId=").append(wxId);
sb.append(", wxUnionId=").append(wxUnionId);
sb.append(", wmOpenId=").append(wmOpenId);
sb.append(", status=").append(status);
sb.append(", roles=").append(roles);
sb.append(", source=").append(source);
sb.append(", createTime=").append(createTime);
sb.append(", updateUserId=").append(updateUserId);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -1295,6 +1295,76 @@ public class SysAccountExample {
return (Criteria) this;
}
public Criteria andSourceIsNull() {
addCriterion("`source` is null");
return (Criteria) this;
}
public Criteria andSourceIsNotNull() {
addCriterion("`source` is not null");
return (Criteria) this;
}
public Criteria andSourceEqualTo(String value) {
addCriterion("`source` =", value, "source");
return (Criteria) this;
}
public Criteria andSourceNotEqualTo(String value) {
addCriterion("`source` <>", value, "source");
return (Criteria) this;
}
public Criteria andSourceGreaterThan(String value) {
addCriterion("`source` >", value, "source");
return (Criteria) this;
}
public Criteria andSourceGreaterThanOrEqualTo(String value) {
addCriterion("`source` >=", value, "source");
return (Criteria) this;
}
public Criteria andSourceLessThan(String value) {
addCriterion("`source` <", value, "source");
return (Criteria) this;
}
public Criteria andSourceLessThanOrEqualTo(String value) {
addCriterion("`source` <=", value, "source");
return (Criteria) this;
}
public Criteria andSourceLike(String value) {
addCriterion("`source` like", value, "source");
return (Criteria) this;
}
public Criteria andSourceNotLike(String value) {
addCriterion("`source` not like", value, "source");
return (Criteria) this;
}
public Criteria andSourceIn(List<String> values) {
addCriterion("`source` in", values, "source");
return (Criteria) this;
}
public Criteria andSourceNotIn(List<String> values) {
addCriterion("`source` not in", values, "source");
return (Criteria) this;
}
public Criteria andSourceBetween(String value1, String value2) {
addCriterion("`source` between", value1, value2, "source");
return (Criteria) this;
}
public Criteria andSourceNotBetween(String value1, String value2) {
addCriterion("`source` not between", value1, value2, "source");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.services;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.SysAccount;
import club.joylink.rtss.entity.SysAccountExample;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserQueryVO;
@ -10,6 +11,8 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.user.AccountCreateVO;
import club.joylink.rtss.vo.client.user.AccountRegisterQueryVO;
import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
import club.joylink.rtss.vo.wx.WmUserSession;
import lombok.NonNull;
@ -322,4 +325,8 @@ public interface ISysUserService {
void logicDelete(Long id);
boolean isThirdParentAccountExist(String parentAccount);
AccountRegisterStatisticsVO statisticRegisterCount(AccountRegisterQueryVO queryVO);
List<SysAccount> findEntitiesBySource(String source);
}

View File

@ -82,4 +82,11 @@ public interface IUserUsageStatsService {
List<UsageTotalStatsVO> totalDuration(boolean filter);
List<UserRankStatsVO> queryTrainingUsageGroupByUser(LocalDateTime start, LocalDateTime end, List<Long> lessonIds, List<Long> userIds);
/**
* 统计实训使用时长
* @param accountSource 只统计这些来源的账户的使用时长
* @return 使用时长
*/
long statisticTrainingUsageDuration(String accountSource);
}

View File

@ -21,6 +21,8 @@ import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.user.AccountCreateVO;
import club.joylink.rtss.vo.client.user.AccountRegisterQueryVO;
import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
import club.joylink.rtss.vo.wx.WmUserSession;
import club.joylink.rtss.vo.wx.WxUserGet;
import com.github.pagehelper.Page;
@ -873,6 +875,7 @@ public class SysUserService implements ISysUserService {
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(this.isSameEmailExist(accountCreateVO.getEmail()));
SysAccount account = accountCreateVO.toDB();
account.setRoles(BusinessConsts.ROLE_01);
account.setSource(accountCreateVO.getSource());
account.setCreateTime(LocalDateTime.now());
account.setStatus(StatusEnum.Valid.getCode());
this.sysAccountDAO.insertSelective(account);
@ -963,6 +966,29 @@ public class SysUserService implements ISysUserService {
return this.sysAccountDAO.countByExample(example) > 0;
}
@Override
public AccountRegisterStatisticsVO statisticRegisterCount(AccountRegisterQueryVO queryVO) {
SysAccountExample example = new SysAccountExample();
SysAccountExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasText(queryVO.getSource())) {
criteria.andSourceEqualTo(queryVO.getSource());
}
int total = (int) sysAccountDAO.countByExample(example);
LocalDateTime now = LocalDateTime.now();
LocalDateTime todayStart = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime yesterdayStart = todayStart.minusDays(1);
criteria.andCreateTimeBetween(yesterdayStart, todayStart);
int newRegistrationYesterday = (int) sysAccountDAO.countByExample(example);
return new AccountRegisterStatisticsVO(total, newRegistrationYesterday);
}
@Override
public List<SysAccount> findEntitiesBySource(String source) {
SysAccountExample example = new SysAccountExample();
example.createCriteria().andSourceEqualTo(source);
return sysAccountDAO.selectByExample(example);
}
private boolean isSameEmailExist(String email) {
SysAccountExample example = new SysAccountExample();
example.createCriteria()

View File

@ -3,10 +3,7 @@ package club.joylink.rtss.services;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.UserExamMapper;
import club.joylink.rtss.dao.UserTrainingStatsMapper;
import club.joylink.rtss.entity.UserExam;
import club.joylink.rtss.entity.UserExamExample;
import club.joylink.rtss.entity.UserTrainingStats;
import club.joylink.rtss.entity.UserTrainingStatsExample;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.user.IUserSimulationStatService;
import club.joylink.rtss.vo.AccountVO;
@ -48,6 +45,9 @@ public class UserUsageStatsService implements IUserUsageStatsService {
@Autowired
private IMapService iMapService;
@Autowired
private ISysUserService iSysUserService;
@Override
public List<UserRankStatsVO> queryLessonList(AccountVO accountVO) {
return this.userTrainingStatsMapper.queryLessonList(accountVO.getId());
@ -158,6 +158,18 @@ public class UserUsageStatsService implements IUserUsageStatsService {
return this.userTrainingStatsMapper.selectUsage(start, end, lessonIds, userIds);
}
@Override
public long statisticTrainingUsageDuration(String accountSource) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(accountSource, "账户来源不能为空");
List<SysAccount> accounts = iSysUserService.findEntitiesBySource(accountSource);
List<Long> accountIds = accounts.stream().map(SysAccount::getId).collect(Collectors.toList());
UserTrainingStatsExample example = new UserTrainingStatsExample();
example.createCriteria()
.andUserIdIn(accountIds)
.andFakeEqualTo(false);
return userTrainingStatsMapper.countByExample(example);
}
public static void addMyRank(List<UserRankStatsVO> rankList, AccountVO accountVO) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(rankList);
for(int i = 0; i < rankList.size(); i++) {

View File

@ -4,9 +4,9 @@ import club.joylink.rtss.entity.Training;
import club.joylink.rtss.services.training.data.GenerateConfig;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.UserTrainingListVO;
import club.joylink.rtss.vo.client.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.UserTrainingVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingListVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingVO;
import club.joylink.rtss.vo.client.training.*;
import lombok.NonNull;

View File

@ -19,9 +19,9 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.UserTrainingListVO;
import club.joylink.rtss.vo.client.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.UserTrainingVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingListVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingQueryVO;
import club.joylink.rtss.vo.client.trainingUsage.UserTrainingVO;
import club.joylink.rtss.vo.client.training.*;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.graph.MapAutomaticRouteButtonVO;

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.simulation.cbtc.message.UserSimulationStatsManager;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.org.StudentsUsageStatisticsVO;
import club.joylink.rtss.vo.client.simulationUsage.*;
import java.time.LocalDateTime;
import java.util.List;
@ -89,4 +90,10 @@ public interface IUserSimulationStatService {
List<UsageTotalStatsVO> totalDuration(boolean filter, List<Long> userIds);
List<StudentsUsageStatisticsVO> querySimulationUsage(long mapId, List<Long> userIds, LocalDateTime startTime, LocalDateTime endTime);
/**
* 统计仿真使用时长分行调和现地
* @param accountSource 只统计这个来源的账户的数据
*/
SimulationUsageStatisticsVO statisticSimulationUsage(String accountSource);
}

View File

@ -2,21 +2,25 @@ package club.joylink.rtss.services.user;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.dao.UserSimulationStatsDAO;
import club.joylink.rtss.entity.SysAccount;
import club.joylink.rtss.entity.UserSimulationStats;
import club.joylink.rtss.entity.UserSimulationStatsExample;
import club.joylink.rtss.event.UserSimulationRecordEvent;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.services.UserUsageStatsService;
import club.joylink.rtss.simulation.cbtc.message.UserSimulationStatsManager;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.org.StudentsUsageStatisticsVO;
import club.joylink.rtss.vo.client.simulationUsage.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
@ -34,6 +38,8 @@ public class UserSimulationStatService implements IUserSimulationStatService {
@Autowired
private IMapService iMapService;
@Autowired
private ISysUserService iSysUserService;
@Override
public void addUserSimulationStats(UserSimulationStatsVO statsVO, AccountVO accountVO) {
@ -139,4 +145,22 @@ public class UserSimulationStatService implements IUserSimulationStatService {
public List<StudentsUsageStatisticsVO> querySimulationUsage(long mapId, List<Long> userIds, LocalDateTime startTime, LocalDateTime endTime) {
return userSimulationStatsDAO.queryUsage(mapId, userIds, startTime, endTime);
}
@Override
public SimulationUsageStatisticsVO statisticSimulationUsage(String accountSource) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(accountSource, "账户来源不能为空");
List<SysAccount> accounts = iSysUserService.findEntitiesBySource(accountSource);
List<Long> accountIds = accounts.stream().map(SysAccount::getId).collect(Collectors.toList());
UserSimulationStatsExample example = new UserSimulationStatsExample();
example.createCriteria()
.andUserIdIn(accountIds)
.andPrdTypeEqualTo(MapPrdTypeEnum.LOCAL.getCode());
long durationOfLocalSimulation = userSimulationStatsDAO.countByExample(example);
example.clear();
example.createCriteria()
.andUserIdIn(accountIds)
.andPrdTypeEqualTo(MapPrdTypeEnum.CENTER.getCode());
long durationOfCenterSimulation = userSimulationStatsDAO.countByExample(example);
return new SimulationUsageStatisticsVO(durationOfLocalSimulation, durationOfCenterSimulation);
}
}

View File

@ -0,0 +1,32 @@
package club.joylink.rtss.vo.client.simulationUsage;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalTime;
/**
* 仿真使用情况统计
*/
@Getter
public class SimulationUsageStatisticsVO {
/**
* 现地仿真的使用时长
*/
@JsonSerialize(using = ToStringSerializer.class)
private long durationOfLocalSimulation;
/**
* 行调仿真的使用时长
*/
@JsonSerialize(using = ToStringSerializer.class)
private long durationOfCenterSimulation;
public SimulationUsageStatisticsVO(long durationOfLocalSimulation, long durationOfCenterSimulation) {
this.durationOfLocalSimulation = durationOfLocalSimulation;
this.durationOfCenterSimulation = durationOfCenterSimulation;
}
}

View File

@ -1,4 +1,4 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.simulationUsage;
import lombok.Getter;
import lombok.NoArgsConstructor;

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.simulationUsage;
import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -7,7 +8,7 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserSimulationStatsQueryVO extends PageQueryVO{
public class UserSimulationStatsQueryVO extends PageQueryVO {
private String userName;

View File

@ -1,4 +1,4 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.simulationUsage;
import club.joylink.rtss.entity.UserSimulationStats;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

View File

@ -1,4 +1,4 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.trainingUsage;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.trainingUsage;
import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,4 +1,4 @@
package club.joylink.rtss.vo.client;
package club.joylink.rtss.vo.client.trainingUsage;
import club.joylink.rtss.entity.UserTrainingStats;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.vo.client.user;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class AccountRegisterQueryVO {
/**
* 账号来源
*/
private String source;
}

View File

@ -0,0 +1,24 @@
package club.joylink.rtss.vo.client.user;
import lombok.Getter;
/**
* 账号注册统计
*/
@Getter
public class AccountRegisterStatisticsVO {
/**
* 总用户数
*/
private int total;
/**
* 昨日新增注册数
*/
private int newRegistrationYesterday;
public AccountRegisterStatisticsVO(int total, int newRegistrationYesterday) {
this.total = total;
this.newRegistrationYesterday = newRegistrationYesterday;
}
}

View File

@ -49,6 +49,11 @@ public class AccountCreateVO {
*/
private String avatarPath;
/**
* 账号来源
*/
private String source;
public SysAccount toDB() {
SysAccount account = new SysAccount();
account.setAccount(this.account);

View File

@ -19,6 +19,7 @@
<result column="wm_open_id" jdbcType="VARCHAR" property="wmOpenId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="roles" jdbcType="VARCHAR" property="roles" />
<result column="source" jdbcType="VARCHAR" property="source" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
@ -83,8 +84,8 @@
</sql>
<sql id="Base_Column_List">
id, account, parent_account, `type`, org_id, `name`, nickname, avatar_path, `password`,
mobile, nationcode, email, wx_id, wx_union_id, wm_open_id, `status`, roles, create_time,
update_user_id, update_time
mobile, nationcode, email, wx_id, wx_union_id, wm_open_id, `status`, roles, `source`,
create_time, update_user_id, update_time
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.SysAccountExample" resultMap="BaseResultMap">
select
@ -130,15 +131,15 @@
avatar_path, `password`, mobile,
nationcode, email, wx_id,
wx_union_id, wm_open_id, `status`,
roles, create_time, update_user_id,
update_time)
roles, `source`, create_time,
update_user_id, update_time)
values (#{account,jdbcType=VARCHAR}, #{parentAccount,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{orgId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR},
#{avatarPath,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{nationcode,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{wxId,jdbcType=VARCHAR},
#{wxUnionId,jdbcType=VARCHAR}, #{wmOpenId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{roles,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT},
#{updateTime,jdbcType=TIMESTAMP})
#{roles,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.SysAccount" useGeneratedKeys="true">
insert into sys_account
@ -191,6 +192,9 @@
<if test="roles != null">
roles,
</if>
<if test="source != null">
`source`,
</if>
<if test="createTime != null">
create_time,
</if>
@ -250,6 +254,9 @@
<if test="roles != null">
#{roles,jdbcType=VARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
@ -321,6 +328,9 @@
<if test="record.roles != null">
roles = #{record.roles,jdbcType=VARCHAR},
</if>
<if test="record.source != null">
`source` = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
@ -354,6 +364,7 @@
wm_open_id = #{record.wmOpenId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
roles = #{record.roles,jdbcType=VARCHAR},
`source` = #{record.source,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_user_id = #{record.updateUserId,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
@ -412,6 +423,9 @@
<if test="roles != null">
roles = #{roles,jdbcType=VARCHAR},
</if>
<if test="source != null">
`source` = #{source,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
@ -442,71 +456,10 @@
wm_open_id = #{wmOpenId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
roles = #{roles,jdbcType=VARCHAR},
`source` = #{source,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_user_id = #{updateUserId,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<!--额外添加-->
<resultMap id="WithCompanyMap" type="club.joylink.rtss.vo.AccountVO">
<id column="userId" jdbcType="BIGINT" property="id" />
<result column="account" jdbcType="VARCHAR" property="account" />
<result column="userName" jdbcType="VARCHAR" property="name" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="avatar_path" jdbcType="VARCHAR" property="avatarPath" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="nationcode" jdbcType="VARCHAR" property="nationcode" />
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="wx_id" jdbcType="VARCHAR" property="wxId" />
<result column="wx_union_id" jdbcType="VARCHAR" property="wxUnionId" />
<result column="wm_open_id" jdbcType="VARCHAR" property="wmOpenId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="roles" jdbcType="VARCHAR" property="dbRoles" />
<result column="sys_account.create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="companyId" property="companyId"/>
<result column="companyName" property="companyName"/>
<result column="companyAdmin" property="companyAdmin"/>
<result column="projectCode" property="projectCode"/>
</resultMap>
<select id="queryUsersWithCompany" parameterType="club.joylink.rtss.vo.UserQueryVO" resultMap="WithCompanyMap">
SELECT t.*,o.root_id AS companyId,
(SELECT `name` FROM org og WHERE og.id = companyId) AS companyName,
(SELECT `project_code` FROM org WHERE id = o.root_id) AS projectCode,
(SELECT COUNT(1) FROM org_user oue WHERE oue.org_id = companyId AND user_id=t.userId) AS companyAdmin
FROM
(SELECT s.id as userId, account, s.`name` as userName, nickname, avatar_path, `password`, mobile, nationcode, email,wx_id, wx_union_id, wm_open_id, `status`, roles, `offline`, s.create_time, update_user_id,s.update_time,
SUBSTRING_INDEX (GROUP_CONCAT(org_id),',',1) AS org_id
FROM sys_account s LEFT JOIN org_user cu ON s.id=cu.user_id GROUP BY s.id) t
LEFT JOIN org o ON o.id = t.org_id
<where>
<if test="name != null and name != ''">
and t.`userName` like concat('%', #{name}, '%')
</if>
<if test="nickname != null and nickname != ''">
and t.`nickname` like concat('%', #{nickname}, '%')
</if>
<if test="mobile != null and mobile != ''">
and t.`mobile` like concat('%', #{mobile}, '%')
</if>
<if test="rolesStr != null and rolesStr != ''">
and t.`roles` like concat('%', #{rolesStr}, '%')
</if>
<if test="companyId != null">
and o.id = #{companyId}
</if>
</where>
order by t.userId
</select>
<select id="queryUserWithCompany" resultMap="WithCompanyMap">
SELECT t.*,o.root_id AS companyId,
(SELECT `name` FROM org WHERE id = o.root_id) AS companyName,
(SELECT `project_code` FROM org WHERE id = o.root_id) AS projectCode,
(SELECT COUNT(1) FROM org_user WHERE org_id = o.root_id AND user_id=#{userId}) AS companyAdmin
FROM (SELECT s.id as userId, account, s.`name` as userName, nickname, avatar_path, `password`, mobile, nationcode, email,
wx_id, wx_union_id, wm_open_id, `status`, roles, `offline`, s.create_time, update_user_id,s.update_time, cu.org_id FROM sys_account s LEFT JOIN org_user cu ON s.id=cu.user_id WHERE s.id = #{userId} LIMIT 1) t
LEFT JOIN org o ON o.id = t.org_id
</select>
</mapper>