diff --git a/sql/20210623-sheng-userdata.sql b/sql/20210623-sheng-userdata.sql new file mode 100644 index 000000000..68805b1be --- /dev/null +++ b/sql/20210623-sheng-userdata.sql @@ -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; diff --git a/src/main/java/club/joylink/rtss/configuration/TaskExecutorConfiguration.java b/src/main/java/club/joylink/rtss/configuration/TaskExecutorConfiguration.java index bf71f6fbb..8c1575ac5 100644 --- a/src/main/java/club/joylink/rtss/configuration/TaskExecutorConfiguration.java +++ b/src/main/java/club/joylink/rtss/configuration/TaskExecutorConfiguration.java @@ -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(); diff --git a/src/main/java/club/joylink/rtss/configuration/WebConfig.java b/src/main/java/club/joylink/rtss/configuration/WebConfig.java index 44a817f28..75884ddc4 100644 --- a/src/main/java/club/joylink/rtss/configuration/WebConfig.java +++ b/src/main/java/club/joylink/rtss/configuration/WebConfig.java @@ -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); } diff --git a/src/main/java/club/joylink/rtss/controller/OrgController.java b/src/main/java/club/joylink/rtss/controller/OrgController.java index cae9fae31..f6f503feb 100644 --- a/src/main/java/club/joylink/rtss/controller/OrgController.java +++ b/src/main/java/club/joylink/rtss/controller/OrgController.java @@ -328,10 +328,10 @@ public class OrgController { return iOrgExamService.queryOrgExam(clsId, user); } + /** + *管理员查看组织树 + */ @Role(RoleEnum.Admin) -/** - *管理员查看组织树 - */ @GetMapping("/orgTree/{orgId}") public Node adminQueryOrgTree(@PathVariable Long orgId, @RequestAttribute AccountVO user) { return iOrgService.adminQueryOrgTree(orgId); diff --git a/src/main/java/club/joylink/rtss/controller/test/TestController.java b/src/main/java/club/joylink/rtss/controller/test/TestController.java new file mode 100644 index 000000000..882f78999 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/test/TestController.java @@ -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); + } + +} diff --git a/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java b/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java new file mode 100644 index 000000000..4bc6ea20b --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java @@ -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); + } + +} diff --git a/src/main/java/club/joylink/rtss/dao/SysThirdAccountConfigDAO.java b/src/main/java/club/joylink/rtss/dao/SysThirdAccountConfigDAO.java new file mode 100644 index 000000000..28f0abd6e --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/SysThirdAccountConfigDAO.java @@ -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 selectByExampleWithBLOBs(SysThirdAccountConfigExample example); + + List 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); +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/dao/UserSimulationStatsDAO.java b/src/main/java/club/joylink/rtss/dao/UserSimulationStatsDAO.java index bbbddabf1..5feb1b86a 100644 --- a/src/main/java/club/joylink/rtss/dao/UserSimulationStatsDAO.java +++ b/src/main/java/club/joylink/rtss/dao/UserSimulationStatsDAO.java @@ -111,5 +111,25 @@ public interface UserSimulationStatsDAO extends MyBatisBaseDao" + + "SELECT" + + " sum(duration) AS simulationDuration," + + " user_id as userId" + + " FROM" + + " user_simulation_stats" + + " WHERE" + + " map_id = #{mapId}" + + " " + + " and end_time >= #{startTime}" + + " " + + " " + + " and end_time <= #{endTime}" + + " " + + " AND user_id IN" + + " " + + " #{userId}" + + " " + + " GROUP BY user_id;" + + "") List queryUsage(long mapId, List userIds, LocalDateTime startTime, LocalDateTime endTime); } diff --git a/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfig.java b/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfig.java new file mode 100644 index 000000000..cae71a8dc --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfig.java @@ -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; +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfigExample.java b/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfigExample.java new file mode 100644 index 000000000..7e4cabf90 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/SysThirdAccountConfigExample.java @@ -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 oredCriteria; + + private Integer limit; + + private Long offset; + + public SysThirdAccountConfigExample() { + oredCriteria = new ArrayList(); + } + + 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 values) { + addCriterion("account in", values, "account"); + return (Criteria) this; + } + + public Criteria andAccountNotIn(List 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 values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List 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 values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/UserSimulationStats.java b/src/main/java/club/joylink/rtss/entity/UserSimulationStats.java index ac66dd47a..46ab741ab 100644 --- a/src/main/java/club/joylink/rtss/entity/UserSimulationStats.java +++ b/src/main/java/club/joylink/rtss/entity/UserSimulationStats.java @@ -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(); - } } \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/UserSimulationStatsExample.java b/src/main/java/club/joylink/rtss/entity/UserSimulationStatsExample.java index bf5a46219..52842fa46 100644 --- a/src/main/java/club/joylink/rtss/entity/UserSimulationStatsExample.java +++ b/src/main/java/club/joylink/rtss/entity/UserSimulationStatsExample.java @@ -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 values) { - addCriterion("map_prd_id in", values, "mapPrdId"); - return (Criteria) this; - } - - public Criteria andMapPrdIdNotIn(List 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 values) { - addCriterion("duration in", values, "duration"); - return (Criteria) this; - } - - public Criteria andDurationNotIn(List 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 values) { - addCriterion("fake in", values, "fake"); + public Criteria andStartTimeIn(List values) { + addCriterion("start_time in", values, "startTime"); return (Criteria) this; } - public Criteria andFakeNotIn(List values) { - addCriterion("fake not in", values, "fake"); + public Criteria andStartTimeNotIn(List 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 values) { + addCriterion("duration in", values, "duration"); + return (Criteria) this; + } + + public Criteria andDurationNotIn(List 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 values) { + addCriterion("fake in", values, "fake"); + return (Criteria) this; + } + + public Criteria andFakeNotIn(List 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; + } } /** diff --git a/src/main/java/club/joylink/rtss/event/UserExamRecordEvent.java b/src/main/java/club/joylink/rtss/event/UserExamRecordEvent.java new file mode 100644 index 000000000..dd8919e16 --- /dev/null +++ b/src/main/java/club/joylink/rtss/event/UserExamRecordEvent.java @@ -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; + } +} diff --git a/src/main/java/club/joylink/rtss/event/UserSimulationRecordEvent.java b/src/main/java/club/joylink/rtss/event/UserSimulationRecordEvent.java new file mode 100644 index 000000000..f0e7ec239 --- /dev/null +++ b/src/main/java/club/joylink/rtss/event/UserSimulationRecordEvent.java @@ -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; + } +} diff --git a/src/main/java/club/joylink/rtss/services/SysUserService.java b/src/main/java/club/joylink/rtss/services/SysUserService.java index 571532b3d..9ae709970 100644 --- a/src/main/java/club/joylink/rtss/services/SysUserService.java +++ b/src/main/java/club/joylink/rtss/services/SysUserService.java @@ -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 diff --git a/src/main/java/club/joylink/rtss/services/UserExamService.java b/src/main/java/club/joylink/rtss/services/UserExamService.java index 5b8f79a6b..90a591280 100644 --- a/src/main/java/club/joylink/rtss/services/UserExamService.java +++ b/src/main/java/club/joylink/rtss/services/UserExamService.java @@ -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 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 questionsVOs = new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/services/org/OrgService.java b/src/main/java/club/joylink/rtss/services/org/OrgService.java index 2aecbb047..656d4879c 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgService.java @@ -381,8 +381,8 @@ public class OrgService implements IOrgService { criteria.andStatusEqualTo(status); } List 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; } diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java new file mode 100644 index 000000000..5d82e7d5a --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java @@ -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); +} diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java new file mode 100644 index 000000000..376bdb726 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java @@ -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 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 list = this.sysThirdAccountConfigDAO.selectByExampleWithBLOBs(example); + return list.isEmpty() ? null : list.get(0); + } +} diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java new file mode 100644 index 000000000..bd9dd1a56 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java @@ -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 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 syncRecordData = this.buildSyncUserExamRecordData(accountVO, record); + this.postToThird(config.getUserSimulationRecordSyncUrl(), syncRecordData); + } + + private AccountVO queryAccountVO(Long userId) { + AccountVO accountVO = null; + List 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 syncRecordData) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + String body = JsonUtils.writeValueAsString(syncRecordData); + HttpEntity httpEntity = new HttpEntity<>(body, headers); + ResponseEntity responseEntity = this.restTemplate.postForEntity(url, httpEntity, String.class); + } + + private Map buildSyncUserSimulationRecordData(AccountVO accountVO, UserSimulationStats record) { + Map 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 buildSyncUserExamRecordData(AccountVO accountVO, UserExam record) { + Map 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; + } +} diff --git a/src/main/java/club/joylink/rtss/services/user/IUserSimulationStatService.java b/src/main/java/club/joylink/rtss/services/user/IUserSimulationStatService.java index 1702c9ca0..94e83dde0 100644 --- a/src/main/java/club/joylink/rtss/services/user/IUserSimulationStatService.java +++ b/src/main/java/club/joylink/rtss/services/user/IUserSimulationStatService.java @@ -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); /** * 分页查询用户仿真数据 diff --git a/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java b/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java index 061ddb0a1..bd799ce4c 100644 --- a/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java +++ b/src/main/java/club/joylink/rtss/services/user/UserSimulationStatService.java @@ -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 diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java index 385004171..21bf8359b 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java @@ -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; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index 06ae709e1..97ddade92 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -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); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index 4c73d2a1d..07518dd38 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -216,6 +216,10 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation 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 groupKeyUseInfos = simulationAndUseInfosMap.computeIfAbsent(group, k -> new HashSet<>()); groupKeyUseInfos.add(newInfo); @@ -102,14 +108,8 @@ public class UserSimulationStatsManager { Set 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; } } diff --git a/src/main/java/club/joylink/rtss/vo/AccountVO.java b/src/main/java/club/joylink/rtss/vo/AccountVO.java index efddcaa3c..0334fee6d 100644 --- a/src/main/java/club/joylink/rtss/vo/AccountVO.java +++ b/src/main/java/club/joylink/rtss/vo/AccountVO.java @@ -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); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/UserSimulationStatsVO.java b/src/main/java/club/joylink/rtss/vo/client/UserSimulationStatsVO.java index 84e7b6fb1..8f9996fde 100644 --- a/src/main/java/club/joylink/rtss/vo/client/UserSimulationStatsVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/UserSimulationStatsVO.java @@ -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; diff --git a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java new file mode 100644 index 000000000..b9be7dc3b --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java @@ -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); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java new file mode 100644 index 000000000..719fa6374 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java @@ -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; +} diff --git a/src/main/resources/mybatis/mapper/SysThirdAccountConfigDAO.xml b/src/main/resources/mybatis/mapper/SysThirdAccountConfigDAO.xml new file mode 100644 index 000000000..3c5e68c76 --- /dev/null +++ b/src/main/resources/mybatis/mapper/SysThirdAccountConfigDAO.xml @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, account, create_time, update_time + + + interface_config + + + + + + delete from sys_third_account_config + where id = #{id,jdbcType=BIGINT} + + + delete from sys_third_account_config + + + + + + 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 into sys_third_account_config + + + account, + + + create_time, + + + update_time, + + + interface_config, + + + + + #{account,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{interfaceConfig,jdbcType=LONGVARCHAR}, + + + + + + update sys_third_account_config + + + 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}, + + + + + + + + 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} + + + + + + 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} + + + + + + update sys_third_account_config + + + 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 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 sys_third_account_config + set account = #{account,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/UserSimulationStatsDAO.xml b/src/main/resources/mybatis/mapper/UserSimulationStatsDAO.xml index a1cfe9a83..fbbd45f38 100644 --- a/src/main/resources/mybatis/mapper/UserSimulationStatsDAO.xml +++ b/src/main/resources/mybatis/mapper/UserSimulationStatsDAO.xml @@ -5,12 +5,12 @@ - - - + + + @@ -71,7 +71,7 @@ - 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 @@ -192,24 +192,24 @@ 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}, + + start_time = #{record.startTime,jdbcType=TIMESTAMP}, end_time = #{record.endTime,jdbcType=TIMESTAMP}, + + duration = #{record.duration,jdbcType=INTEGER}, + + + fake = #{record.fake,jdbcType=TINYINT}, + @@ -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} @@ -239,24 +239,24 @@ 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}, + + start_time = #{startTime,jdbcType=TIMESTAMP}, end_time = #{endTime,jdbcType=TIMESTAMP}, + + duration = #{duration,jdbcType=INTEGER}, + + + fake = #{fake,jdbcType=TINYINT}, + where id = #{id,jdbcType=BIGINT} @@ -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} - - - - + \ No newline at end of file