Merge branch 'test' into dev

This commit is contained in:
joylink_zhangsai 2021-06-23 18:48:18 +08:00
commit 7a3bea2fee
33 changed files with 1533 additions and 410 deletions

View File

@ -0,0 +1,21 @@
ALTER TABLE `user_simulation_stats`
DROP COLUMN `map_prd_id`,
MODIFY COLUMN `role` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户角色' AFTER `prd_type`,
MODIFY COLUMN `end_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP COMMENT '结束时间' AFTER `role`,
MODIFY COLUMN `duration` int(11) NOT NULL COMMENT '有效时长' AFTER `end_time`,
ADD COLUMN `start_time` datetime NOT NULL DEFAULT now() ON UPDATE CURRENT_TIMESTAMP COMMENT '开始时间' AFTER `role`;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for sys_third_account_config
-- ----------------------------
DROP TABLE IF EXISTS `sys_third_account_config`;
CREATE TABLE `sys_third_account_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`account` varchar(32) NOT NULL COMMENT '第三方账户账号',
`interface_config` text COMMENT '接口信息配置',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

View File

@ -6,7 +6,6 @@ import org.springframework.core.env.Environment;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.util.concurrent.ThreadPoolExecutor;
@ -22,8 +21,24 @@ public class TaskExecutorConfiguration {
public TaskExecutor nsExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("ns-executor-");
taskExecutor.setCorePoolSize(4);
taskExecutor.setMaxPoolSize(4);
taskExecutor.setCorePoolSize(2);
taskExecutor.setMaxPoolSize(2);
taskExecutor.setQueueCapacity(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
/***
* 第三方账户数据同步执行线程池
* @return
*/
@Bean("thirdAccountDataSyncExecutor")
public TaskExecutor thirdAccountDataSyncExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("third-account-sync-executor-");
taskExecutor.setCorePoolSize(2);
taskExecutor.setMaxPoolSize(2);
taskExecutor.setQueueCapacity(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
@ -38,8 +53,8 @@ public class TaskExecutorConfiguration {
public TaskExecutor realDeviceExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("real-device-executor-");
taskExecutor.setCorePoolSize(4);
taskExecutor.setMaxPoolSize(4);
taskExecutor.setCorePoolSize(2);
taskExecutor.setMaxPoolSize(2);
taskExecutor.setQueueCapacity(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();

View File

@ -59,6 +59,7 @@ public class WebConfig implements WebMvcConfigurer {
//项目域名查询
whiteList.add("/api/projectServer/project/{project}");
whiteList.add("/test/simulation/**");
whiteList.add("/api/test/**");
registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList);
}

View File

@ -328,10 +328,10 @@ public class OrgController {
return iOrgExamService.queryOrgExam(clsId, user);
}
/**
*管理员查看组织树
*/
@Role(RoleEnum.Admin)
/**
*管理员查看组织树
*/
@GetMapping("/orgTree/{orgId}")
public Node<Object> adminQueryOrgTree(@PathVariable Long orgId, @RequestAttribute AccountVO user) {
return iOrgService.adminQueryOrgTree(orgId);

View File

@ -0,0 +1,22 @@
package club.joylink.rtss.controller.test;
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.RestController;
@RestController
@RequestMapping("/api/test")
public class TestController {
@PostMapping("/thirdsync/usr")
public void thirdSyncSimulationRecord(@RequestBody String json) {
System.out.println(json);
}
@PostMapping("/thirdsync/uer")
public void thirdSyncExamRecord(@RequestBody String json) {
System.out.println(json);
}
}

View File

@ -0,0 +1,22 @@
package club.joylink.rtss.controller.user;
import club.joylink.rtss.services.thridAccount.ThirdAccountConfigService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/thirdAccountConfig")
public class ThirdAccountConfigController {
@Autowired
private ThirdAccountConfigService thirdAccountConfigService;
@PostMapping("")
public void saveOrUpdate(@RequestBody @Validated ThirdAccountConfigVO configVO, @RequestAttribute AccountVO user) {
this.thirdAccountConfigService.saveOrUpdateConfig(configVO);
}
}

View File

@ -0,0 +1,41 @@
package club.joylink.rtss.dao;
import club.joylink.rtss.entity.SysThirdAccountConfig;
import club.joylink.rtss.entity.SysThirdAccountConfigExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface SysThirdAccountConfigDAO {
long countByExample(SysThirdAccountConfigExample example);
int deleteByExample(SysThirdAccountConfigExample example);
int deleteByPrimaryKey(Long id);
int insert(SysThirdAccountConfig record);
int insertSelective(SysThirdAccountConfig record);
List<SysThirdAccountConfig> selectByExampleWithBLOBs(SysThirdAccountConfigExample example);
List<SysThirdAccountConfig> selectByExample(SysThirdAccountConfigExample example);
SysThirdAccountConfig selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SysThirdAccountConfig record, @Param("example") SysThirdAccountConfigExample example);
int updateByExampleWithBLOBs(@Param("record") SysThirdAccountConfig record, @Param("example") SysThirdAccountConfigExample example);
int updateByExample(@Param("record") SysThirdAccountConfig record, @Param("example") SysThirdAccountConfigExample example);
int updateByPrimaryKeySelective(SysThirdAccountConfig record);
int updateByPrimaryKeyWithBLOBs(SysThirdAccountConfig record);
int updateByPrimaryKey(SysThirdAccountConfig record);
}

View File

@ -111,5 +111,25 @@ public interface UserSimulationStatsDAO extends MyBatisBaseDao<UserSimulationSta
"map_prd_id=#{prdId} ")
void fillPrdType(Long prdId, String prdType);
@Select("<script>" +
"SELECT" +
" sum(duration) AS simulationDuration," +
" user_id as userId" +
" FROM" +
" user_simulation_stats" +
" WHERE" +
" map_id = #{mapId}" +
" <if test=\"startTime != null\">" +
" and end_time &gt;= #{startTime}" +
" </if>" +
" <if test=\"endTime != null\">" +
" and end_time &lt;= #{endTime}" +
" </if>" +
" AND user_id IN" +
" <foreach collection=\"userIds\" item=\"userId\" open=\"(\" separator=\",\" close=\")\">" +
" #{userId}" +
" </foreach>" +
" GROUP BY user_id;" +
"</script>")
List<StudentsUsageStatisticsVO> queryUsage(long mapId, List<Long> userIds, LocalDateTime startTime, LocalDateTime endTime);
}

View File

@ -0,0 +1,37 @@
package club.joylink.rtss.entity;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author
*
*/
@Data
public class SysThirdAccountConfig implements Serializable {
private Long id;
/**
* 第三方账户账号
*/
private String account;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 接口信息配置
*/
private String interfaceConfig;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,473 @@
package club.joylink.rtss.entity;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
public class SysThirdAccountConfigExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public SysThirdAccountConfigExample() {
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 andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andAccountIsNull() {
addCriterion("account is null");
return (Criteria) this;
}
public Criteria andAccountIsNotNull() {
addCriterion("account is not null");
return (Criteria) this;
}
public Criteria andAccountEqualTo(String value) {
addCriterion("account =", value, "account");
return (Criteria) this;
}
public Criteria andAccountNotEqualTo(String value) {
addCriterion("account <>", value, "account");
return (Criteria) this;
}
public Criteria andAccountGreaterThan(String value) {
addCriterion("account >", value, "account");
return (Criteria) this;
}
public Criteria andAccountGreaterThanOrEqualTo(String value) {
addCriterion("account >=", value, "account");
return (Criteria) this;
}
public Criteria andAccountLessThan(String value) {
addCriterion("account <", value, "account");
return (Criteria) this;
}
public Criteria andAccountLessThanOrEqualTo(String value) {
addCriterion("account <=", value, "account");
return (Criteria) this;
}
public Criteria andAccountLike(String value) {
addCriterion("account like", value, "account");
return (Criteria) this;
}
public Criteria andAccountNotLike(String value) {
addCriterion("account not like", value, "account");
return (Criteria) this;
}
public Criteria andAccountIn(List<String> values) {
addCriterion("account in", values, "account");
return (Criteria) this;
}
public Criteria andAccountNotIn(List<String> values) {
addCriterion("account not in", values, "account");
return (Criteria) this;
}
public Criteria andAccountBetween(String value1, String value2) {
addCriterion("account between", value1, value2, "account");
return (Criteria) this;
}
public Criteria andAccountNotBetween(String value1, String value2) {
addCriterion("account not between", value1, value2, "account");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(LocalDateTime value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(LocalDateTime value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(LocalDateTime value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(LocalDateTime value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(LocalDateTime value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<LocalDateTime> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<LocalDateTime> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
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);
}
}
}

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.entity;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -7,6 +9,7 @@ import java.time.LocalDateTime;
* @author
* 用户仿真统计
*/
@Data
public class UserSimulationStats implements Serializable {
private Long id;
@ -20,163 +23,35 @@ public class UserSimulationStats implements Serializable {
*/
private Long mapId;
/**
* 产品编码
*/
private Long mapPrdId;
/**
* 产品类型
*/
private String prdType;
/**
* 用时
*/
private Integer duration;
/**
* 用户角色
*/
private String role;
/**
* 开始时间
*/
private LocalDateTime startTime;
/**
* 结束时间
*/
private LocalDateTime endTime;
/**
* 有效时长
*/
private Integer duration;
/**
* 假数据
*/
private Boolean fake;
private LocalDateTime endTime;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getMapId() {
return mapId;
}
public void setMapId(Long mapId) {
this.mapId = mapId;
}
public Long getMapPrdId() {
return mapPrdId;
}
public void setMapPrdId(Long mapPrdId) {
this.mapPrdId = mapPrdId;
}
public String getPrdType() {
return prdType;
}
public void setPrdType(String prdType) {
this.prdType = prdType;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public Boolean getFake() {
return fake;
}
public void setFake(Boolean fake) {
this.fake = fake;
}
public LocalDateTime getEndTime() {
return endTime;
}
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
UserSimulationStats other = (UserSimulationStats) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId()))
&& (this.getMapPrdId() == null ? other.getMapPrdId() == null : this.getMapPrdId().equals(other.getMapPrdId()))
&& (this.getPrdType() == null ? other.getPrdType() == null : this.getPrdType().equals(other.getPrdType()))
&& (this.getDuration() == null ? other.getDuration() == null : this.getDuration().equals(other.getDuration()))
&& (this.getRole() == null ? other.getRole() == null : this.getRole().equals(other.getRole()))
&& (this.getFake() == null ? other.getFake() == null : this.getFake().equals(other.getFake()))
&& (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode());
result = prime * result + ((getMapPrdId() == null) ? 0 : getMapPrdId().hashCode());
result = prime * result + ((getPrdType() == null) ? 0 : getPrdType().hashCode());
result = prime * result + ((getDuration() == null) ? 0 : getDuration().hashCode());
result = prime * result + ((getRole() == null) ? 0 : getRole().hashCode());
result = prime * result + ((getFake() == null) ? 0 : getFake().hashCode());
result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().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(", userId=").append(userId);
sb.append(", mapId=").append(mapId);
sb.append(", mapPrdId=").append(mapPrdId);
sb.append(", prdType=").append(prdType);
sb.append(", duration=").append(duration);
sb.append(", role=").append(role);
sb.append(", fake=").append(fake);
sb.append(", endTime=").append(endTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -305,66 +305,6 @@ public class UserSimulationStatsExample {
return (Criteria) this;
}
public Criteria andMapPrdIdIsNull() {
addCriterion("map_prd_id is null");
return (Criteria) this;
}
public Criteria andMapPrdIdIsNotNull() {
addCriterion("map_prd_id is not null");
return (Criteria) this;
}
public Criteria andMapPrdIdEqualTo(Long value) {
addCriterion("map_prd_id =", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdNotEqualTo(Long value) {
addCriterion("map_prd_id <>", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdGreaterThan(Long value) {
addCriterion("map_prd_id >", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdGreaterThanOrEqualTo(Long value) {
addCriterion("map_prd_id >=", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdLessThan(Long value) {
addCriterion("map_prd_id <", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdLessThanOrEqualTo(Long value) {
addCriterion("map_prd_id <=", value, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdIn(List<Long> values) {
addCriterion("map_prd_id in", values, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdNotIn(List<Long> values) {
addCriterion("map_prd_id not in", values, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdBetween(Long value1, Long value2) {
addCriterion("map_prd_id between", value1, value2, "mapPrdId");
return (Criteria) this;
}
public Criteria andMapPrdIdNotBetween(Long value1, Long value2) {
addCriterion("map_prd_id not between", value1, value2, "mapPrdId");
return (Criteria) this;
}
public Criteria andPrdTypeIsNull() {
addCriterion("prd_type is null");
return (Criteria) this;
@ -435,66 +375,6 @@ public class UserSimulationStatsExample {
return (Criteria) this;
}
public Criteria andDurationIsNull() {
addCriterion("duration is null");
return (Criteria) this;
}
public Criteria andDurationIsNotNull() {
addCriterion("duration is not null");
return (Criteria) this;
}
public Criteria andDurationEqualTo(Integer value) {
addCriterion("duration =", value, "duration");
return (Criteria) this;
}
public Criteria andDurationNotEqualTo(Integer value) {
addCriterion("duration <>", value, "duration");
return (Criteria) this;
}
public Criteria andDurationGreaterThan(Integer value) {
addCriterion("duration >", value, "duration");
return (Criteria) this;
}
public Criteria andDurationGreaterThanOrEqualTo(Integer value) {
addCriterion("duration >=", value, "duration");
return (Criteria) this;
}
public Criteria andDurationLessThan(Integer value) {
addCriterion("duration <", value, "duration");
return (Criteria) this;
}
public Criteria andDurationLessThanOrEqualTo(Integer value) {
addCriterion("duration <=", value, "duration");
return (Criteria) this;
}
public Criteria andDurationIn(List<Integer> values) {
addCriterion("duration in", values, "duration");
return (Criteria) this;
}
public Criteria andDurationNotIn(List<Integer> values) {
addCriterion("duration not in", values, "duration");
return (Criteria) this;
}
public Criteria andDurationBetween(Integer value1, Integer value2) {
addCriterion("duration between", value1, value2, "duration");
return (Criteria) this;
}
public Criteria andDurationNotBetween(Integer value1, Integer value2) {
addCriterion("duration not between", value1, value2, "duration");
return (Criteria) this;
}
public Criteria andRoleIsNull() {
addCriterion("`role` is null");
return (Criteria) this;
@ -565,63 +445,63 @@ public class UserSimulationStatsExample {
return (Criteria) this;
}
public Criteria andFakeIsNull() {
addCriterion("fake is null");
public Criteria andStartTimeIsNull() {
addCriterion("start_time is null");
return (Criteria) this;
}
public Criteria andFakeIsNotNull() {
addCriterion("fake is not null");
public Criteria andStartTimeIsNotNull() {
addCriterion("start_time is not null");
return (Criteria) this;
}
public Criteria andFakeEqualTo(Boolean value) {
addCriterion("fake =", value, "fake");
public Criteria andStartTimeEqualTo(LocalDateTime value) {
addCriterion("start_time =", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeNotEqualTo(Boolean value) {
addCriterion("fake <>", value, "fake");
public Criteria andStartTimeNotEqualTo(LocalDateTime value) {
addCriterion("start_time <>", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeGreaterThan(Boolean value) {
addCriterion("fake >", value, "fake");
public Criteria andStartTimeGreaterThan(LocalDateTime value) {
addCriterion("start_time >", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeGreaterThanOrEqualTo(Boolean value) {
addCriterion("fake >=", value, "fake");
public Criteria andStartTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("start_time >=", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeLessThan(Boolean value) {
addCriterion("fake <", value, "fake");
public Criteria andStartTimeLessThan(LocalDateTime value) {
addCriterion("start_time <", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeLessThanOrEqualTo(Boolean value) {
addCriterion("fake <=", value, "fake");
public Criteria andStartTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("start_time <=", value, "startTime");
return (Criteria) this;
}
public Criteria andFakeIn(List<Boolean> values) {
addCriterion("fake in", values, "fake");
public Criteria andStartTimeIn(List<LocalDateTime> values) {
addCriterion("start_time in", values, "startTime");
return (Criteria) this;
}
public Criteria andFakeNotIn(List<Boolean> values) {
addCriterion("fake not in", values, "fake");
public Criteria andStartTimeNotIn(List<LocalDateTime> values) {
addCriterion("start_time not in", values, "startTime");
return (Criteria) this;
}
public Criteria andFakeBetween(Boolean value1, Boolean value2) {
addCriterion("fake between", value1, value2, "fake");
public Criteria andStartTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("start_time between", value1, value2, "startTime");
return (Criteria) this;
}
public Criteria andFakeNotBetween(Boolean value1, Boolean value2) {
addCriterion("fake not between", value1, value2, "fake");
public Criteria andStartTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("start_time not between", value1, value2, "startTime");
return (Criteria) this;
}
@ -684,6 +564,126 @@ public class UserSimulationStatsExample {
addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andDurationIsNull() {
addCriterion("duration is null");
return (Criteria) this;
}
public Criteria andDurationIsNotNull() {
addCriterion("duration is not null");
return (Criteria) this;
}
public Criteria andDurationEqualTo(Integer value) {
addCriterion("duration =", value, "duration");
return (Criteria) this;
}
public Criteria andDurationNotEqualTo(Integer value) {
addCriterion("duration <>", value, "duration");
return (Criteria) this;
}
public Criteria andDurationGreaterThan(Integer value) {
addCriterion("duration >", value, "duration");
return (Criteria) this;
}
public Criteria andDurationGreaterThanOrEqualTo(Integer value) {
addCriterion("duration >=", value, "duration");
return (Criteria) this;
}
public Criteria andDurationLessThan(Integer value) {
addCriterion("duration <", value, "duration");
return (Criteria) this;
}
public Criteria andDurationLessThanOrEqualTo(Integer value) {
addCriterion("duration <=", value, "duration");
return (Criteria) this;
}
public Criteria andDurationIn(List<Integer> values) {
addCriterion("duration in", values, "duration");
return (Criteria) this;
}
public Criteria andDurationNotIn(List<Integer> values) {
addCriterion("duration not in", values, "duration");
return (Criteria) this;
}
public Criteria andDurationBetween(Integer value1, Integer value2) {
addCriterion("duration between", value1, value2, "duration");
return (Criteria) this;
}
public Criteria andDurationNotBetween(Integer value1, Integer value2) {
addCriterion("duration not between", value1, value2, "duration");
return (Criteria) this;
}
public Criteria andFakeIsNull() {
addCriterion("fake is null");
return (Criteria) this;
}
public Criteria andFakeIsNotNull() {
addCriterion("fake is not null");
return (Criteria) this;
}
public Criteria andFakeEqualTo(Boolean value) {
addCriterion("fake =", value, "fake");
return (Criteria) this;
}
public Criteria andFakeNotEqualTo(Boolean value) {
addCriterion("fake <>", value, "fake");
return (Criteria) this;
}
public Criteria andFakeGreaterThan(Boolean value) {
addCriterion("fake >", value, "fake");
return (Criteria) this;
}
public Criteria andFakeGreaterThanOrEqualTo(Boolean value) {
addCriterion("fake >=", value, "fake");
return (Criteria) this;
}
public Criteria andFakeLessThan(Boolean value) {
addCriterion("fake <", value, "fake");
return (Criteria) this;
}
public Criteria andFakeLessThanOrEqualTo(Boolean value) {
addCriterion("fake <=", value, "fake");
return (Criteria) this;
}
public Criteria andFakeIn(List<Boolean> values) {
addCriterion("fake in", values, "fake");
return (Criteria) this;
}
public Criteria andFakeNotIn(List<Boolean> values) {
addCriterion("fake not in", values, "fake");
return (Criteria) this;
}
public Criteria andFakeBetween(Boolean value1, Boolean value2) {
addCriterion("fake between", value1, value2, "fake");
return (Criteria) this;
}
public Criteria andFakeNotBetween(Boolean value1, Boolean value2) {
addCriterion("fake not between", value1, value2, "fake");
return (Criteria) this;
}
}
/**

View File

@ -0,0 +1,14 @@
package club.joylink.rtss.event;
import club.joylink.rtss.entity.UserExam;
import lombok.Getter;
@Getter
public class UserExamRecordEvent {
UserExam record;
public UserExamRecordEvent(UserExam record) {
this.record = record;
}
}

View File

@ -0,0 +1,13 @@
package club.joylink.rtss.event;
import club.joylink.rtss.entity.UserSimulationStats;
import lombok.Getter;
@Getter
public class UserSimulationRecordEvent {
UserSimulationStats record;
public UserSimulationRecordEvent(UserSimulationStats record) {
this.record = record;
}
}

View File

@ -210,7 +210,7 @@ public class SysUserService implements ISysUserService {
public AccountVO findUserById(Long id) {
Objects.requireNonNull(id);
SysAccount sysAccount = this.sysAccountDAO.selectByPrimaryKey(id);
return new AccountVO(sysAccount);
return sysAccount == null ? null : new AccountVO(sysAccount);
}
@Override

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.services;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.*;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.event.UserExamRecordEvent;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.org.IOrgService;
import club.joylink.rtss.services.org.IOrgUserService;
@ -15,6 +16,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -28,7 +30,8 @@ import java.util.stream.Collectors;
@Service
@Slf4j
public class UserExamService implements IUserExamService {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ExamDefinitionDAO examDefinitionDAO;
@ -114,7 +117,12 @@ public class UserExamService implements IUserExamService {
collect.addAll(value);
}
}
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(collect.size() >= rule.getNum());
if (collect == null) {
collect = new ArrayList<>();
}
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(collect.size() >= rule.getNum(),
String.format("考试规则[实训类型:%s,操作类型:%s,数量:%s],没有足够数量的实训: %s",
rule.getTrainingType(), rule.getOperateType(), rule.getNum(), collect.size()));
// 随机生成考试并保存
boolean flag = true;
List<UserExamQuestionsVO> questionsVOs = new ArrayList<>();
@ -205,9 +213,11 @@ public class UserExamService implements IUserExamService {
// 判断是否已经计算
if (userExam.getResult().equals(BusinessConsts.Exam.Result.Result01)) {
// 总分
float score = 0;
for (UserExamQuestions question : questionList) {
userExam.setScore(userExam.getScore() + question.getScore());
score += question.getScore();
}
userExam.setScore(score);
// 结果
if (userExam.getScore() >= examDefinition.getPassingPoint()) {
userExam.setResult(BusinessConsts.Exam.Result.Result02);
@ -218,6 +228,7 @@ public class UserExamService implements IUserExamService {
userExam.setEndTime(new Date());
userExam.setUsedTime((int) Duration.between(userExam.getStartTime().toInstant(), userExam.getEndTime().toInstant()).getSeconds());
this.userExamMapper.updateByPrimaryKey(userExam);
this.applicationContext.publishEvent(new UserExamRecordEvent(userExam));
}
UserExamVO userExamVO = new UserExamVO(userExam);
List<UserExamQuestionsVO> questionsVOs = new ArrayList<>();

View File

@ -381,8 +381,8 @@ public class OrgService implements IOrgService {
criteria.andStatusEqualTo(status);
}
List<Org> orgs = orgDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs,
String.format("没有顶级组织id为[%s]的组织", rootId));
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs,
// String.format("没有顶级组织id为[%s]的组织", rootId));
return orgs;
}

View File

@ -0,0 +1,11 @@
package club.joylink.rtss.services.thridAccount;
import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO;
import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig;
public interface ThirdAccountConfigService {
void saveOrUpdateConfig(ThirdAccountConfigVO configVO);
ThirdInterfaceConfig getInterfaceConfigByAccountId(String account);
}

View File

@ -0,0 +1,73 @@
package club.joylink.rtss.services.thridAccount;
import club.joylink.rtss.dao.SysThirdAccountConfigDAO;
import club.joylink.rtss.entity.SysThirdAccountConfig;
import club.joylink.rtss.entity.SysThirdAccountConfigExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.cache.ICacheService;
import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO;
import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class ThirdAccountConfigServiceImpl implements ThirdAccountConfigService {
public static final String InterfaceConfigCacheKeyPre = "Third-Interface-Config-";
@Autowired
private SysThirdAccountConfigDAO sysThirdAccountConfigDAO;
@Autowired
private ICacheService iCacheService;
@Override
public void saveOrUpdateConfig(ThirdAccountConfigVO configVO) {
SysThirdAccountConfig existed = this.queryEntityBy(configVO.getAccount());
LocalDateTime now = LocalDateTime.now();
if (existed == null) {
SysThirdAccountConfig db = configVO.toDB();
db.setCreateTime(now);
this.sysThirdAccountConfigDAO.insertSelective(db);
} else {
existed.setInterfaceConfig(configVO.getInterfaceConfigJson());
existed.setUpdateTime(now);
this.sysThirdAccountConfigDAO.updateByPrimaryKeySelective(existed);
}
this.iCacheService.remove(this.buildInterfaceConfigCacheKey(configVO.getAccount()));
}
@Override
public ThirdInterfaceConfig getInterfaceConfigByAccountId(String account) {
String key = this.buildInterfaceConfigCacheKey(account);
ThirdInterfaceConfig config = (ThirdInterfaceConfig) this.iCacheService.get(key);
if (config == null) {
SysThirdAccountConfig entity = this.queryEntityWithBLOBsBy(account);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity,
String.format("账户[%s]的第三方接口配置不存在", account));
config = ThirdAccountConfigVO.readInterfaceConfig(entity.getInterfaceConfig());
this.iCacheService.put(key, config);
}
return config;
}
private String buildInterfaceConfigCacheKey(String account) {
return String.format(String.format("%s%s", InterfaceConfigCacheKeyPre, account));
}
private SysThirdAccountConfig queryEntityBy(String account) {
SysThirdAccountConfigExample example = new SysThirdAccountConfigExample();
example.createCriteria()
.andAccountEqualTo(account);
List<SysThirdAccountConfig> list = this.sysThirdAccountConfigDAO.selectByExample(example);
return list.isEmpty() ? null : list.get(0);
}
private SysThirdAccountConfig queryEntityWithBLOBsBy(String account) {
SysThirdAccountConfigExample example = new SysThirdAccountConfigExample();
example.createCriteria()
.andAccountEqualTo(account);
List<SysThirdAccountConfig> list = this.sysThirdAccountConfigDAO.selectByExampleWithBLOBs(example);
return list.isEmpty() ? null : list.get(0);
}
}

View File

@ -0,0 +1,127 @@
package club.joylink.rtss.services.thridAccount;
import club.joylink.rtss.entity.UserExam;
import club.joylink.rtss.entity.UserSimulationStats;
import club.joylink.rtss.event.UserExamRecordEvent;
import club.joylink.rtss.event.UserSimulationRecordEvent;
import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.services.LoginSessionManager;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig;
import 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.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ThirdAccountDataSyncService {
@Autowired
private ISysUserService iSysUserService;
@Autowired
private LoginSessionManager loginSessionManager;
@Autowired
private ThirdAccountConfigService thirdAccountConfigService;
@Autowired
private RestTemplate restTemplate;
@Async("thirdAccountDataSyncExecutor")
@EventListener
public void syncUserSimulationUsing(UserSimulationRecordEvent event) {
UserSimulationStats record = event.getRecord();
AccountVO accountVO = this.queryAccountVO(record.getUserId());
if (accountVO == null) { // 不是第三方账号,返回
return;
}
String parentAccount = accountVO.getParentAccount();
ThirdInterfaceConfig config = this.thirdAccountConfigService.getInterfaceConfigByAccountId(parentAccount);
Map<String, Object> syncRecordData = this.buildSyncUserSimulationRecordData(accountVO, record);
this.postToThird(config.getUserSimulationRecordSyncUrl(), syncRecordData);
}
@Async("thirdAccountDataSyncExecutor")
@EventListener
public void syncUserExamResult(UserExamRecordEvent event) {
UserExam record = event.getRecord();
AccountVO accountVO = this.queryAccountVO(record.getUserId());
if (accountVO == null) { // 不是第三方账号,返回
return;
}
String parentAccount = accountVO.getParentAccount();
ThirdInterfaceConfig config = this.thirdAccountConfigService.getInterfaceConfigByAccountId(parentAccount);
Map<String, Object> syncRecordData = this.buildSyncUserExamRecordData(accountVO, record);
this.postToThird(config.getUserSimulationRecordSyncUrl(), syncRecordData);
}
private AccountVO queryAccountVO(Long userId) {
AccountVO accountVO = null;
List<LoginUserInfoVO> loginInfoList = this.loginSessionManager.queryLoginInfoByUserId(userId);
if (!CollectionUtils.isEmpty(loginInfoList)) { // 用户在线
if (loginInfoList.get(0).getAccountVO().isThirdChildAccount()) {
accountVO = loginInfoList.get(0).getAccountVO();
}
} else {
AccountVO vo = this.iSysUserService.findUserById(userId);
if (vo != null && vo.isThirdChildAccount()) {
accountVO = vo;
}
}
return accountVO;
}
private void postToThird(String url, Map<String, Object> syncRecordData) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String body = JsonUtils.writeValueAsString(syncRecordData);
HttpEntity<String> httpEntity = new HttpEntity<>(body, headers);
ResponseEntity<String> responseEntity = this.restTemplate.postForEntity(url, httpEntity, String.class);
}
private Map<String, Object> buildSyncUserSimulationRecordData(AccountVO accountVO, UserSimulationStats record) {
Map<String, Object> map = new HashMap<>();
map.put("userId", accountVO.getAccount());
map.put("startTime", record.getStartTime());
map.put("endTime", record.getEndTime());
map.put("duration", record.getDuration());
return map;
}
private Map<String, Object> buildSyncUserExamRecordData(AccountVO accountVO, UserExam record) {
Map<String, Object> map = new HashMap<>();
map.put("userId", accountVO.getAccount());
map.put("examName", record.getExamName());
map.put("usedTime", record.getUsedTime());
map.put("score", record.getScore());
return map;
}
private static class SyncUserSimulationRecord {
String userId;
/**
* 开始时间
*/
private LocalDateTime startTime;
/**
* 结束时间
*/
private LocalDateTime endTime;
/**
* 有效时长
*/
private Integer duration;
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.services.user;
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;
@ -18,13 +19,9 @@ public interface IUserSimulationStatService {
/**
* 添加用户仿真数据
* @param userId
* @param mapId
* @param prdType
* @param duration
* @param role
* @param info
*/
void addUserSimulationStats(Long userId, Long mapId, String prdType, Integer duration, String role);
void addUserSimulationStats(UserSimulationStatsManager.SimulationUseInfo info);
/**
* 分页查询用户仿真数据

View File

@ -4,15 +4,18 @@ import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.dao.UserSimulationStatsDAO;
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.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 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 java.time.LocalDateTime;
@ -24,6 +27,8 @@ import java.util.stream.Collectors;
@Service
public class UserSimulationStatService implements IUserSimulationStatService {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private UserSimulationStatsDAO userSimulationStatsDAO;
@ -39,16 +44,18 @@ public class UserSimulationStatService implements IUserSimulationStatService {
}
@Override
public void addUserSimulationStats(Long userId, Long mapId, String prdType, Integer duration, String role) {
public void addUserSimulationStats(UserSimulationStatsManager.SimulationUseInfo info) {
UserSimulationStats userSimulationStats = new UserSimulationStats();
userSimulationStats.setUserId(userId);
userSimulationStats.setMapId(mapId);
userSimulationStats.setPrdType(prdType);
userSimulationStats.setDuration(duration);
userSimulationStats.setFake(false);
userSimulationStats.setRole(role);
userSimulationStats.setUserId(info.getUserId());
userSimulationStats.setMapId(info.getMapId());
userSimulationStats.setPrdType(info.getPrdType());
userSimulationStats.setRole(info.getMemberType());
userSimulationStats.setStartTime(info.getStartTime());
userSimulationStats.setEndTime(LocalDateTime.now());
userSimulationStats.setDuration(info.getDuration());
userSimulationStats.setFake(false);
this.userSimulationStatsDAO.insertSelective(userSimulationStats);
this.applicationContext.publishEvent(new UserSimulationRecordEvent(userSimulationStats));
}
@Override

View File

@ -1,12 +1,11 @@
package club.joylink.rtss.simulation;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.event.SimulationDestroyEvent;
import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent;
import club.joylink.rtss.simulation.event.SimulationFaultRemoveEvent;
import club.joylink.rtss.simulation.event.SimulationMemberPlayChangeEvent;
import club.joylink.rtss.simulation.messaging.websocket.DefaultMessageSender;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.RtSimulationUser;
import club.joylink.rtss.simulation.vo.SimulationFaultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -110,6 +109,9 @@ public class SimulationManager {
public Simulation destroy(String id) {
Simulation simulation = simulationCache.remove(id);
if (simulation != null) {
if (simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation) {
this.applicationContext.publishEvent(new SimulationDestroyEvent(this, (club.joylink.rtss.simulation.cbtc.Simulation) simulation));
}
simulation.destroy();
}
return simulation;

View File

@ -493,7 +493,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
}
if (Objects.equals(simulation.getBuildParams().getUser().getId(), user.getId()) ||
user.isAdmin()) { // 是仿真创建者或管理员可以清理
this.simulationLifeCycleService.destroy(simulation);
// this.simulationLifeCycleService.destroy(simulation);
simulationManager.destroy(simulation.getId());
this.groupSimulationCache.removeSimulation(group);
this.iTrainingV1Service.removeGroupTraining(group);

View File

@ -216,6 +216,10 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
return FunctionalType.SCRIPT_PREVIEW.equals(buildParams.getFunctionalType());
}
public boolean isExamSimulation() {
return FunctionalType.EXAM.equals(buildParams.getFunctionalType());
}
/**
* 获取该角色类型的所有成员
*/

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.services.IVoiceCommandService;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop;
@ -22,7 +23,6 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
import club.joylink.rtss.services.IVoiceCommandService;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop;
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
@ -157,7 +157,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
@Override
public void destroy(Simulation simulation) {
this.applicationContext.publishEvent(new SimulationDestroyEvent(this, simulation));
// this.applicationContext.publishEvent(new SimulationDestroyEvent(this, simulation));
}
@Override

View File

@ -47,7 +47,8 @@ public class UserSimulationStatsManager {
*/
public void subscribeSimulation(Long userId, String group) {
Simulation simulation = groupSimulationService.getSimulationByGroup(group);
if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation()) {
if (simulation.isScriptMakingSimulation() || simulation.isScriptPreviewSimulation() ||
simulation.isExamSimulation()) {
return;
}
Set<SimulationUseInfo> useInfos = userAndUseInfosMap.computeIfAbsent(userId, k -> new HashSet<>());
@ -56,7 +57,12 @@ public class UserSimulationStatsManager {
SimulationUseInfo useInfo = infoOptional.get();
useInfo.restart();
} else { //如果记录不存在
SimulationUseInfo newInfo = new SimulationUseInfo(group, userId);
SimulationMember member = simulation.querySimulationMemberByUserId(userId);
String memberType = member == null ? null : member.getType().name();
SimulationBuildParams buildParams = simulation.getBuildParams();
Long mapId = buildParams.getMap().getId();
String prdType = buildParams.getProdType() == null ? null : buildParams.getProdType().getCode();
SimulationUseInfo newInfo = new SimulationUseInfo(group, userId, mapId, prdType, memberType);
useInfos.add(newInfo);
Set<SimulationUseInfo> groupKeyUseInfos = simulationAndUseInfosMap.computeIfAbsent(group, k -> new HashSet<>());
groupKeyUseInfos.add(newInfo);
@ -102,14 +108,8 @@ public class UserSimulationStatsManager {
Set<SimulationUseInfo> infos = userAndUseInfosMap.get(info.getUserId());
infos.removeIf(i -> group.equals(i.getGroup()));
});
SimulationBuildParams buildParams = simulation.getBuildParams();
useInfos.forEach(info -> {
Long userId = info.getUserId();
SimulationMember member = simulation.querySimulationMemberByUserId(userId);
String memberType = member == null ? null : member.getType().name();
String prdType = buildParams.getProdType() == null ? null : buildParams.getProdType().getCode();
iUserSimulationStatService.addUserSimulationStats(userId, buildParams.getMap().getId(),
prdType, info.getDuration(), memberType);
iUserSimulationStatService.addUserSimulationStats(info);
});
}
@ -130,18 +130,31 @@ public class UserSimulationStatsManager {
@Setter
public class SimulationUseInfo {
private String group;
private Long mapId;
private String prdType;
private String memberType;
private Long userId;
private LocalDateTime startTime = LocalDateTime.now();
/**
* 仿真开始时间
*/
private LocalDateTime startTime;
/**
* 计时开始时间
*/
private LocalDateTime countTime;
private int duration;
private boolean pause;
public SimulationUseInfo(String group, Long userId) {
public SimulationUseInfo(String group, Long userId, Long mapId, String prdType, String memberType) {
this.group = group;
this.userId = userId;
this.mapId = mapId;
this.prdType = prdType;
this.memberType = memberType;
LocalDateTime now = LocalDateTime.now();
this.startTime = now;
this.countTime = now;
}
/**
@ -149,7 +162,7 @@ public class UserSimulationStatsManager {
*/
public void pause() {
if (!pause) {
duration = (int) (duration + Duration.between(startTime, LocalDateTime.now()).toSeconds());
duration = (int) (duration + Duration.between(countTime, LocalDateTime.now()).toSeconds());
this.pause = true;
}
}
@ -159,7 +172,7 @@ public class UserSimulationStatsManager {
*/
public void restart() {
if (pause) {
startTime = LocalDateTime.now();
countTime = LocalDateTime.now();
pause = false;
}
}

View File

@ -306,7 +306,8 @@ public class AccountVO implements Serializable {
}
}
@JsonIgnore
public boolean isThirdChildAccount() {
return this.type == Type_3 && StringUtils.hasText(this.parentAccount);
return Type_3.equalsIgnoreCase(this.type) && StringUtils.hasText(this.parentAccount);
}
}

View File

@ -10,6 +10,7 @@ import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -42,6 +43,15 @@ public class UserSimulationStatsVO {
*/
private String prdType;
/**
* 开始时间
*/
private LocalDateTime startTime;
/**
* 结束时间
*/
private LocalDateTime endTime;
/**
* 用时
*/
@ -66,6 +76,8 @@ public class UserSimulationStatsVO {
stats.setUserId(this.getUserId());
stats.setMapId(this.getMapId());
stats.setPrdType(this.getPrdType());
stats.setStartTime(this.startTime);
stats.setEndTime(this.endTime);
stats.setDuration(this.getDuration());
stats.setRole(this.getRole());
return stats;

View File

@ -0,0 +1,57 @@
package club.joylink.rtss.vo.thirdAccount;
import club.joylink.rtss.entity.SysThirdAccountConfig;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@Getter
@Setter
@NoArgsConstructor
public class ThirdAccountConfigVO {
private Long id;
/**
* 第三方账户账号
*/
@NotBlank(message = "账号不能为空")
private String account;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 接口信息配置
*/
@NotNull(message = "接口配置不能为空")
private ThirdInterfaceConfig interfaceConfig;
public static ThirdInterfaceConfig readInterfaceConfig(String interfaceConfig) {
return JsonUtils.read(interfaceConfig, ThirdInterfaceConfig.class);
}
public SysThirdAccountConfig toDB() {
SysThirdAccountConfig db = new SysThirdAccountConfig();
db.setAccount(this.account);
db.setInterfaceConfig(this.getInterfaceConfigJson());
return db;
}
@JsonIgnore
public String getInterfaceConfigJson() {
return JsonUtils.writeValueAsString(this.interfaceConfig);
}
}

View File

@ -0,0 +1,15 @@
package club.joylink.rtss.vo.thirdAccount;
import lombok.Getter;
@Getter
public class ThirdInterfaceConfig {
/**
* 用户仿真使用记录同步第三方url
*/
private String userSimulationRecordSyncUrl;
/**
* 用户考试成绩记录同步第三方url
*/
private String userExamRecordSyncUrl;
}

View File

@ -0,0 +1,261 @@
<?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.SysThirdAccountConfigDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.SysThirdAccountConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="account" jdbcType="VARCHAR" property="account" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.SysThirdAccountConfig">
<result column="interface_config" jdbcType="LONGVARCHAR" property="interfaceConfig" />
</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">
id, account, create_time, update_time
</sql>
<sql id="Blob_Column_List">
interface_config
</sql>
<select id="selectByExampleWithBLOBs" parameterType="club.joylink.rtss.entity.SysThirdAccountConfigExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from sys_third_account_config
<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="selectByExample" parameterType="club.joylink.rtss.entity.SysThirdAccountConfigExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_third_account_config
<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.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from sys_third_account_config
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from sys_third_account_config
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.SysThirdAccountConfigExample">
delete from sys_third_account_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.SysThirdAccountConfig" useGeneratedKeys="true">
insert into sys_third_account_config (account, create_time, update_time,
interface_config)
values (#{account,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{interfaceConfig,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.SysThirdAccountConfig" useGeneratedKeys="true">
insert into sys_third_account_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="account != null">
account,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="interfaceConfig != null">
interface_config,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="account != null">
#{account,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="interfaceConfig != null">
#{interfaceConfig,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.SysThirdAccountConfigExample" resultType="java.lang.Long">
select count(*) from sys_third_account_config
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_third_account_config
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.account != null">
account = #{record.account,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.interfaceConfig != null">
interface_config = #{record.interfaceConfig,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update sys_third_account_config
set id = #{record.id,jdbcType=BIGINT},
account = #{record.account,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
interface_config = #{record.interfaceConfig,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update sys_third_account_config
set id = #{record.id,jdbcType=BIGINT},
account = #{record.account,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.SysThirdAccountConfig">
update sys_third_account_config
<set>
<if test="account != null">
account = #{account,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="interfaceConfig != null">
interface_config = #{interfaceConfig,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.SysThirdAccountConfig">
update sys_third_account_config
set account = #{account,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
interface_config = #{interfaceConfig,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.SysThirdAccountConfig">
update sys_third_account_config
set account = #{account,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -5,12 +5,12 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="map_id" jdbcType="BIGINT" property="mapId" />
<result column="map_prd_id" jdbcType="BIGINT" property="mapPrdId" />
<result column="prd_type" jdbcType="VARCHAR" property="prdType" />
<result column="duration" jdbcType="INTEGER" property="duration" />
<result column="role" jdbcType="VARCHAR" property="role" />
<result column="fake" jdbcType="TINYINT" property="fake" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="duration" jdbcType="INTEGER" property="duration" />
<result column="fake" jdbcType="TINYINT" property="fake" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -71,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, map_id, map_prd_id, prd_type, duration, `role`, fake, end_time
id, user_id, map_id, prd_type, `role`, start_time, end_time, duration, fake
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.UserSimulationStatsExample" resultMap="BaseResultMap">
select
@ -96,7 +96,7 @@
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from user_simulation_stats
where id = #{id,jdbcType=BIGINT}
@ -112,12 +112,12 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserSimulationStats" useGeneratedKeys="true">
insert into user_simulation_stats (user_id, map_id, map_prd_id,
prd_type, duration, `role`,
fake, end_time)
values (#{userId,jdbcType=BIGINT}, #{mapId,jdbcType=BIGINT}, #{mapPrdId,jdbcType=BIGINT},
#{prdType,jdbcType=VARCHAR}, #{duration,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR},
#{fake,jdbcType=TINYINT}, #{endTime,jdbcType=TIMESTAMP})
insert into user_simulation_stats (user_id, map_id, prd_type,
`role`, start_time, end_time,
duration, fake)
values (#{userId,jdbcType=BIGINT}, #{mapId,jdbcType=BIGINT}, #{prdType,jdbcType=VARCHAR},
#{role,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{duration,jdbcType=INTEGER}, #{fake,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserSimulationStats" useGeneratedKeys="true">
insert into user_simulation_stats
@ -128,24 +128,24 @@
<if test="mapId != null">
map_id,
</if>
<if test="mapPrdId != null">
map_prd_id,
</if>
<if test="prdType != null">
prd_type,
</if>
<if test="duration != null">
duration,
</if>
<if test="role != null">
`role`,
</if>
<if test="fake != null">
fake,
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="duration != null">
duration,
</if>
<if test="fake != null">
fake,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
@ -154,24 +154,24 @@
<if test="mapId != null">
#{mapId,jdbcType=BIGINT},
</if>
<if test="mapPrdId != null">
#{mapPrdId,jdbcType=BIGINT},
</if>
<if test="prdType != null">
#{prdType,jdbcType=VARCHAR},
</if>
<if test="duration != null">
#{duration,jdbcType=INTEGER},
</if>
<if test="role != null">
#{role,jdbcType=VARCHAR},
</if>
<if test="fake != null">
#{fake,jdbcType=TINYINT},
<if test="startTime != null">
#{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
<if test="duration != null">
#{duration,jdbcType=INTEGER},
</if>
<if test="fake != null">
#{fake,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.UserSimulationStatsExample" resultType="java.lang.Long">
@ -192,24 +192,24 @@
<if test="record.mapId != null">
map_id = #{record.mapId,jdbcType=BIGINT},
</if>
<if test="record.mapPrdId != null">
map_prd_id = #{record.mapPrdId,jdbcType=BIGINT},
</if>
<if test="record.prdType != null">
prd_type = #{record.prdType,jdbcType=VARCHAR},
</if>
<if test="record.duration != null">
duration = #{record.duration,jdbcType=INTEGER},
</if>
<if test="record.role != null">
`role` = #{record.role,jdbcType=VARCHAR},
</if>
<if test="record.fake != null">
fake = #{record.fake,jdbcType=TINYINT},
<if test="record.startTime != null">
start_time = #{record.startTime,jdbcType=TIMESTAMP},
</if>
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=TIMESTAMP},
</if>
<if test="record.duration != null">
duration = #{record.duration,jdbcType=INTEGER},
</if>
<if test="record.fake != null">
fake = #{record.fake,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -220,12 +220,12 @@
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
map_id = #{record.mapId,jdbcType=BIGINT},
map_prd_id = #{record.mapPrdId,jdbcType=BIGINT},
prd_type = #{record.prdType,jdbcType=VARCHAR},
duration = #{record.duration,jdbcType=INTEGER},
`role` = #{record.role,jdbcType=VARCHAR},
fake = #{record.fake,jdbcType=TINYINT},
end_time = #{record.endTime,jdbcType=TIMESTAMP}
start_time = #{record.startTime,jdbcType=TIMESTAMP},
end_time = #{record.endTime,jdbcType=TIMESTAMP},
duration = #{record.duration,jdbcType=INTEGER},
fake = #{record.fake,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -239,24 +239,24 @@
<if test="mapId != null">
map_id = #{mapId,jdbcType=BIGINT},
</if>
<if test="mapPrdId != null">
map_prd_id = #{mapPrdId,jdbcType=BIGINT},
</if>
<if test="prdType != null">
prd_type = #{prdType,jdbcType=VARCHAR},
</if>
<if test="duration != null">
duration = #{duration,jdbcType=INTEGER},
</if>
<if test="role != null">
`role` = #{role,jdbcType=VARCHAR},
</if>
<if test="fake != null">
fake = #{fake,jdbcType=TINYINT},
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="duration != null">
duration = #{duration,jdbcType=INTEGER},
</if>
<if test="fake != null">
fake = #{fake,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -264,34 +264,12 @@
update user_simulation_stats
set user_id = #{userId,jdbcType=BIGINT},
map_id = #{mapId,jdbcType=BIGINT},
map_prd_id = #{mapPrdId,jdbcType=BIGINT},
prd_type = #{prdType,jdbcType=VARCHAR},
duration = #{duration,jdbcType=INTEGER},
`role` = #{role,jdbcType=VARCHAR},
fake = #{fake,jdbcType=TINYINT},
end_time = #{endTime,jdbcType=TIMESTAMP}
start_time = #{startTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP},
duration = #{duration,jdbcType=INTEGER},
fake = #{fake,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
<!-- 额外添加 -->
<select id="queryUsage" resultType="club.joylink.rtss.vo.client.org.StudentsUsageStatisticsVO">
SELECT
sum(duration) AS simulationDuration,
user_id as userId
FROM
user_simulation_stats
WHERE
map_id = #{mapId}
<if test="startTime != null">
and end_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and end_time &lt;= #{endTime}
</if>
AND user_id IN
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
GROUP BY user_id;
</select>
</mapper>
</mapper>