diff --git a/sql/20201123.sql b/sql/20201123.sql new file mode 100644 index 000000000..69bf368f1 --- /dev/null +++ b/sql/20201123.sql @@ -0,0 +1,17 @@ +alter table map_data + add version varchar(8) default 0.1 not null comment '版本号'; + +drop table map_version; + +alter table map_data + add time timestamp default now() not null comment '发布时间'; + +alter table map_data + add user_id bigint null comment '发布者的id'; + +alter table map_info + add version varchar(8) default 0.1 not null comment '该地图正在使用的地图数据的版本'; + + + + diff --git a/src/main/java/club/joylink/rtss/controller/user/UserUsageStatsController.java b/src/main/java/club/joylink/rtss/controller/user/UserUsageStatsController.java index 42702c22f..51922b740 100644 --- a/src/main/java/club/joylink/rtss/controller/user/UserUsageStatsController.java +++ b/src/main/java/club/joylink/rtss/controller/user/UserUsageStatsController.java @@ -1,13 +1,15 @@ package club.joylink.rtss.controller.user; +import club.joylink.rtss.constants.RoleEnum; +import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.services.IUserUsageStatsService; import club.joylink.rtss.services.user.IUserSimulationStatService; import club.joylink.rtss.vo.UserVO; -import club.joylink.rtss.vo.client.UsageTotalStatsVO; -import club.joylink.rtss.vo.client.UserRankStatsVO; +import club.joylink.rtss.vo.client.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -95,4 +97,35 @@ public class UserUsageStatsController { public List totalSimulationDuration(boolean filter) { return iUserUsageStatsService.totalDuration(filter); } + + @ApiOperation("分页查询用户仿真数据") + @GetMapping("/simulation") + public PageVO queryPagedStats(UserSimulationStatsQueryVO queryVO) { + return iUserSimulationStatService.queryPagedStats(queryVO); + } + + @Role(value = {RoleEnum.SuperAdmin, RoleEnum.Admin}) + @ApiOperation(value = "添加用户仿真数据") + @PostMapping(path = "/simulation") + public void addUserSimulationStats(@RequestBody @Validated UserSimulationStatsVO statsVO, + @ApiIgnore @RequestAttribute UserVO user) { + iUserSimulationStatService.addUserSimulationStats(statsVO, user); + } + + @Role(value = {RoleEnum.SuperAdmin, RoleEnum.Admin}) + @ApiOperation(value = "更新用户仿真数据") + @PutMapping(path = "/{statsId}") + public void updateUserSimulationStats(@PathVariable Long statsId, + @RequestBody UserSimulationStatsVO statsVO, + @ApiIgnore @RequestAttribute UserVO user) { + iUserSimulationStatService.updateUserSimulationStats(statsId, statsVO, user); + } + + @Role(value = {RoleEnum.SuperAdmin, RoleEnum.Admin}) + @ApiOperation(value = "删除用户仿真数据") + @DeleteMapping(path = "/{statsId}") + public void deleteUserSimulationStats(@PathVariable Long statsId, @ApiIgnore @RequestAttribute UserVO user) { + iUserSimulationStatService.deleteUserSimulationStats(statsId, user); + } + } diff --git a/src/main/java/club/joylink/rtss/dao/MapDataDAO.java b/src/main/java/club/joylink/rtss/dao/MapDataDAO.java index 2412bd89e..08c25c1c1 100644 --- a/src/main/java/club/joylink/rtss/dao/MapDataDAO.java +++ b/src/main/java/club/joylink/rtss/dao/MapDataDAO.java @@ -5,12 +5,13 @@ import club.joylink.rtss.entity.MapDataExample; import club.joylink.rtss.entity.MapDataWithBLOBs; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface MapDataDAO extends MyBatisBaseDao { +public interface MapDataDAO { long countByExample(MapDataExample example); int deleteByExample(MapDataExample example); @@ -40,12 +41,24 @@ public interface MapDataDAO extends MyBatisBaseDao " + " (#{entity.id,jdbcType=BIGINT}, #{entity.mapId,jdbcType=BIGINT}," + - " #{entity.graphData,jdbcType=LONGVARCHAR}, #{entity.logicData,jdbcType=LONGVARCHAR})"+ + " #{entity.graphData,jdbcType=LONGVARCHAR}, #{entity.logicData,jdbcType=LONGVARCHAR}," + + " #{entity.version, jdbcType=VARCHAR}, #{entity.time, jdbcType=TIMESTAMP}, #{entity.userId, jdbcType=BIGINT})"+ " " + "") int batchInsertWithId(@Param("list") List mapDataList); + + @Select("SELECT\n" + + "\tmap_data.version\n" + + "FROM\n" + + "\tmap_data\n" + + "WHERE\n" + + "\tmap_data.map_id = #{mapId}\n" + + "ORDER BY\n" + + "\tmap_data.time DESC\n" + + "LIMIT 1") + String findVersion(Long mapId); } diff --git a/src/main/java/club/joylink/rtss/dao/MapInfoDAO.java b/src/main/java/club/joylink/rtss/dao/MapInfoDAO.java index fa550f669..9fc94af97 100644 --- a/src/main/java/club/joylink/rtss/dao/MapInfoDAO.java +++ b/src/main/java/club/joylink/rtss/dao/MapInfoDAO.java @@ -26,4 +26,4 @@ public interface MapInfoDAO extends MyBatisBaseDao" + "") int batchInsertWithId(@Param("list") List mapInfoList); -} \ No newline at end of file +} diff --git a/src/main/java/club/joylink/rtss/dao/MapVersionDAO.java b/src/main/java/club/joylink/rtss/dao/MapVersionDAO.java deleted file mode 100644 index 038371190..000000000 --- a/src/main/java/club/joylink/rtss/dao/MapVersionDAO.java +++ /dev/null @@ -1,26 +0,0 @@ -package club.joylink.rtss.dao; - -import club.joylink.rtss.entity.MapVersion; -import club.joylink.rtss.entity.MapVersionExample; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * MapVersionDAO继承基类 - */ -@Repository -public interface MapVersionDAO extends MyBatisBaseDao { - - @Insert(value = "") - int batchInsertWithId(@Param("list") List mapVersionList); -} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/MapData.java b/src/main/java/club/joylink/rtss/entity/MapData.java index 08533a583..3bf24d6e3 100644 --- a/src/main/java/club/joylink/rtss/entity/MapData.java +++ b/src/main/java/club/joylink/rtss/entity/MapData.java @@ -1,6 +1,7 @@ package club.joylink.rtss.entity; import java.io.Serializable; +import java.time.LocalDateTime; /** * map_data @@ -14,6 +15,21 @@ public class MapData implements Serializable { */ private Long mapId; + /** + * 版本号 + */ + private String version; + + /** + * 发布时间 + */ + private LocalDateTime time; + + /** + * 发布者的id + */ + private Long userId; + private static final long serialVersionUID = 1L; public Long getId() { @@ -32,6 +48,30 @@ public class MapData implements Serializable { this.mapId = mapId; } + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public LocalDateTime getTime() { + return time; + } + + public void setTime(LocalDateTime time) { + this.time = time; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + @Override public boolean equals(Object that) { if (this == that) { @@ -45,7 +85,10 @@ public class MapData implements Serializable { } MapData other = (MapData) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) - && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())); + && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion())) + && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())); } @Override @@ -54,6 +97,9 @@ public class MapData implements Serializable { int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode()); + result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); return result; } @@ -65,6 +111,9 @@ public class MapData implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", mapId=").append(mapId); + sb.append(", version=").append(version); + sb.append(", time=").append(time); + sb.append(", userId=").append(userId); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); diff --git a/src/main/java/club/joylink/rtss/entity/MapDataExample.java b/src/main/java/club/joylink/rtss/entity/MapDataExample.java index cfb3eeb2d..153f067c3 100644 --- a/src/main/java/club/joylink/rtss/entity/MapDataExample.java +++ b/src/main/java/club/joylink/rtss/entity/MapDataExample.java @@ -1,5 +1,6 @@ package club.joylink.rtss.entity; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -243,6 +244,196 @@ public class MapDataExample { addCriterion("map_id not between", value1, value2, "mapId"); return (Criteria) this; } + + public Criteria andVersionIsNull() { + addCriterion("version is null"); + return (Criteria) this; + } + + public Criteria andVersionIsNotNull() { + addCriterion("version is not null"); + return (Criteria) this; + } + + public Criteria andVersionEqualTo(String value) { + addCriterion("version =", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotEqualTo(String value) { + addCriterion("version <>", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThan(String value) { + addCriterion("version >", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThanOrEqualTo(String value) { + addCriterion("version >=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThan(String value) { + addCriterion("version <", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThanOrEqualTo(String value) { + addCriterion("version <=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLike(String value) { + addCriterion("version like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotLike(String value) { + addCriterion("version not like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionIn(List values) { + addCriterion("version in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotIn(List values) { + addCriterion("version not in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionBetween(String value1, String value2) { + addCriterion("version between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotBetween(String value1, String value2) { + addCriterion("version not between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andTimeIsNull() { + addCriterion("`time` is null"); + return (Criteria) this; + } + + public Criteria andTimeIsNotNull() { + addCriterion("`time` is not null"); + return (Criteria) this; + } + + public Criteria andTimeEqualTo(LocalDateTime value) { + addCriterion("`time` =", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeNotEqualTo(LocalDateTime value) { + addCriterion("`time` <>", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeGreaterThan(LocalDateTime value) { + addCriterion("`time` >", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("`time` >=", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeLessThan(LocalDateTime value) { + addCriterion("`time` <", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeLessThanOrEqualTo(LocalDateTime value) { + addCriterion("`time` <=", value, "time"); + return (Criteria) this; + } + + public Criteria andTimeIn(List values) { + addCriterion("`time` in", values, "time"); + return (Criteria) this; + } + + public Criteria andTimeNotIn(List values) { + addCriterion("`time` not in", values, "time"); + return (Criteria) this; + } + + public Criteria andTimeBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`time` between", value1, value2, "time"); + return (Criteria) this; + } + + public Criteria andTimeNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("`time` not between", value1, value2, "time"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } } /** diff --git a/src/main/java/club/joylink/rtss/entity/MapDataWithBLOBs.java b/src/main/java/club/joylink/rtss/entity/MapDataWithBLOBs.java index 60e4129d6..735457591 100644 --- a/src/main/java/club/joylink/rtss/entity/MapDataWithBLOBs.java +++ b/src/main/java/club/joylink/rtss/entity/MapDataWithBLOBs.java @@ -49,6 +49,9 @@ public class MapDataWithBLOBs extends MapData implements Serializable { MapDataWithBLOBs other = (MapDataWithBLOBs) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())) + && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion())) + && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getGraphData() == null ? other.getGraphData() == null : this.getGraphData().equals(other.getGraphData())) && (this.getLogicData() == null ? other.getLogicData() == null : this.getLogicData().equals(other.getLogicData())); } @@ -59,6 +62,9 @@ public class MapDataWithBLOBs extends MapData implements Serializable { int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getMapId() == null) ? 0 : getMapId().hashCode()); + result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode()); + result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getGraphData() == null) ? 0 : getGraphData().hashCode()); result = prime * result + ((getLogicData() == null) ? 0 : getLogicData().hashCode()); return result; diff --git a/src/main/java/club/joylink/rtss/entity/MapInfo.java b/src/main/java/club/joylink/rtss/entity/MapInfo.java index 1c4527871..a7a58a945 100644 --- a/src/main/java/club/joylink/rtss/entity/MapInfo.java +++ b/src/main/java/club/joylink/rtss/entity/MapInfo.java @@ -49,6 +49,11 @@ public class MapInfo implements Serializable { */ private Integer orderNumber; + /** + * 该地图正在使用的地图数据的版本 + */ + private String version; + private static final long serialVersionUID = 1L; public Long getId() { @@ -123,6 +128,14 @@ public class MapInfo implements Serializable { this.orderNumber = orderNumber; } + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + @Override public boolean equals(Object that) { if (this == that) { @@ -143,7 +156,8 @@ public class MapInfo implements Serializable { && (this.getProject() == null ? other.getProject() == null : this.getProject().equals(other.getProject())) && (this.getProjectCode() == null ? other.getProjectCode() == null : this.getProjectCode().equals(other.getProjectCode())) && (this.getDrawWay() == null ? other.getDrawWay() == null : this.getDrawWay().equals(other.getDrawWay())) - && (this.getOrderNumber() == null ? other.getOrderNumber() == null : this.getOrderNumber().equals(other.getOrderNumber())); + && (this.getOrderNumber() == null ? other.getOrderNumber() == null : this.getOrderNumber().equals(other.getOrderNumber())) + && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion())); } @Override @@ -159,6 +173,7 @@ public class MapInfo implements Serializable { result = prime * result + ((getProjectCode() == null) ? 0 : getProjectCode().hashCode()); result = prime * result + ((getDrawWay() == null) ? 0 : getDrawWay().hashCode()); result = prime * result + ((getOrderNumber() == null) ? 0 : getOrderNumber().hashCode()); + result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode()); return result; } @@ -177,6 +192,7 @@ public class MapInfo implements Serializable { sb.append(", projectCode=").append(projectCode); sb.append(", drawWay=").append(drawWay); sb.append(", orderNumber=").append(orderNumber); + sb.append(", version=").append(version); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); diff --git a/src/main/java/club/joylink/rtss/entity/MapInfoExample.java b/src/main/java/club/joylink/rtss/entity/MapInfoExample.java index cf4fe9167..41cca65f5 100644 --- a/src/main/java/club/joylink/rtss/entity/MapInfoExample.java +++ b/src/main/java/club/joylink/rtss/entity/MapInfoExample.java @@ -713,6 +713,76 @@ public class MapInfoExample { addCriterion("order_number not between", value1, value2, "orderNumber"); return (Criteria) this; } + + public Criteria andVersionIsNull() { + addCriterion("version is null"); + return (Criteria) this; + } + + public Criteria andVersionIsNotNull() { + addCriterion("version is not null"); + return (Criteria) this; + } + + public Criteria andVersionEqualTo(String value) { + addCriterion("version =", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotEqualTo(String value) { + addCriterion("version <>", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThan(String value) { + addCriterion("version >", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThanOrEqualTo(String value) { + addCriterion("version >=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThan(String value) { + addCriterion("version <", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThanOrEqualTo(String value) { + addCriterion("version <=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLike(String value) { + addCriterion("version like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotLike(String value) { + addCriterion("version not like", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionIn(List values) { + addCriterion("version in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotIn(List values) { + addCriterion("version not in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionBetween(String value1, String value2) { + addCriterion("version between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotBetween(String value1, String value2) { + addCriterion("version not between", value1, value2, "version"); + return (Criteria) this; + } } /** diff --git a/src/main/java/club/joylink/rtss/entity/MapVersion.java b/src/main/java/club/joylink/rtss/entity/MapVersion.java deleted file mode 100644 index 792780bdb..000000000 --- a/src/main/java/club/joylink/rtss/entity/MapVersion.java +++ /dev/null @@ -1,121 +0,0 @@ -package club.joylink.rtss.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * map_version - * @author - */ -public class MapVersion implements Serializable { - private Long id; - - /** - * 版本号 - */ - private String version; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - /** - * 作者ID - */ - private Long authorId; - - /** - * 地图id - */ - private Long mapId; - - private static final long serialVersionUID = 1L; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public LocalDateTime getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(LocalDateTime updateTime) { - this.updateTime = updateTime; - } - - public Long getAuthorId() { - return authorId; - } - - public void setAuthorId(Long authorId) { - this.authorId = authorId; - } - - public Long getMapId() { - return mapId; - } - - public void setMapId(Long mapId) { - this.mapId = mapId; - } - - @Override - public boolean equals(Object that) { - if (this == that) { - return true; - } - if (that == null) { - return false; - } - if (getClass() != that.getClass()) { - return false; - } - MapVersion other = (MapVersion) that; - return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) - && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion())) - && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) - && (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId())) - && (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); - result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode()); - result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); - result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode()); - result = prime * result + ((getMapId() == null) ? 0 : getMapId().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(", version=").append(version); - sb.append(", updateTime=").append(updateTime); - sb.append(", authorId=").append(authorId); - sb.append(", mapId=").append(mapId); - 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/MapVersionExample.java b/src/main/java/club/joylink/rtss/entity/MapVersionExample.java deleted file mode 100644 index 9c0a5a964..000000000 --- a/src/main/java/club/joylink/rtss/entity/MapVersionExample.java +++ /dev/null @@ -1,533 +0,0 @@ -package club.joylink.rtss.entity; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -public class MapVersionExample { - protected String orderByClause; - - protected boolean distinct; - - protected List oredCriteria; - - private Integer limit; - - private Long offset; - - public MapVersionExample() { - 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 andVersionIsNull() { - addCriterion("version is null"); - return (Criteria) this; - } - - public Criteria andVersionIsNotNull() { - addCriterion("version is not null"); - return (Criteria) this; - } - - public Criteria andVersionEqualTo(String value) { - addCriterion("version =", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionNotEqualTo(String value) { - addCriterion("version <>", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionGreaterThan(String value) { - addCriterion("version >", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionGreaterThanOrEqualTo(String value) { - addCriterion("version >=", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionLessThan(String value) { - addCriterion("version <", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionLessThanOrEqualTo(String value) { - addCriterion("version <=", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionLike(String value) { - addCriterion("version like", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionNotLike(String value) { - addCriterion("version not like", value, "version"); - return (Criteria) this; - } - - public Criteria andVersionIn(List values) { - addCriterion("version in", values, "version"); - return (Criteria) this; - } - - public Criteria andVersionNotIn(List values) { - addCriterion("version not in", values, "version"); - return (Criteria) this; - } - - public Criteria andVersionBetween(String value1, String value2) { - addCriterion("version between", value1, value2, "version"); - return (Criteria) this; - } - - public Criteria andVersionNotBetween(String value1, String value2) { - addCriterion("version not between", value1, value2, "version"); - 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 Criteria andAuthorIdIsNull() { - addCriterion("author_id is null"); - return (Criteria) this; - } - - public Criteria andAuthorIdIsNotNull() { - addCriterion("author_id is not null"); - return (Criteria) this; - } - - public Criteria andAuthorIdEqualTo(Long value) { - addCriterion("author_id =", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdNotEqualTo(Long value) { - addCriterion("author_id <>", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdGreaterThan(Long value) { - addCriterion("author_id >", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdGreaterThanOrEqualTo(Long value) { - addCriterion("author_id >=", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdLessThan(Long value) { - addCriterion("author_id <", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdLessThanOrEqualTo(Long value) { - addCriterion("author_id <=", value, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdIn(List values) { - addCriterion("author_id in", values, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdNotIn(List values) { - addCriterion("author_id not in", values, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdBetween(Long value1, Long value2) { - addCriterion("author_id between", value1, value2, "authorId"); - return (Criteria) this; - } - - public Criteria andAuthorIdNotBetween(Long value1, Long value2) { - addCriterion("author_id not between", value1, value2, "authorId"); - return (Criteria) this; - } - - public Criteria andMapIdIsNull() { - addCriterion("map_id is null"); - return (Criteria) this; - } - - public Criteria andMapIdIsNotNull() { - addCriterion("map_id is not null"); - return (Criteria) this; - } - - public Criteria andMapIdEqualTo(Long value) { - addCriterion("map_id =", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdNotEqualTo(Long value) { - addCriterion("map_id <>", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdGreaterThan(Long value) { - addCriterion("map_id >", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdGreaterThanOrEqualTo(Long value) { - addCriterion("map_id >=", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdLessThan(Long value) { - addCriterion("map_id <", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdLessThanOrEqualTo(Long value) { - addCriterion("map_id <=", value, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdIn(List values) { - addCriterion("map_id in", values, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdNotIn(List values) { - addCriterion("map_id not in", values, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdBetween(Long value1, Long value2) { - addCriterion("map_id between", value1, value2, "mapId"); - return (Criteria) this; - } - - public Criteria andMapIdNotBetween(Long value1, Long value2) { - addCriterion("map_id not between", value1, value2, "mapId"); - 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/services/MapService.java b/src/main/java/club/joylink/rtss/services/MapService.java index 5206cf960..8bb006118 100644 --- a/src/main/java/club/joylink/rtss/services/MapService.java +++ b/src/main/java/club/joylink/rtss/services/MapService.java @@ -1,19 +1,19 @@ package club.joylink.rtss.services; -import club.joylink.rtss.exception.BaseException; -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.services.training.ITrainingV1Service; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; -import club.joylink.rtss.services.cache.ICacheService; -import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; -import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.MapStatus; import club.joylink.rtss.constants.Project; -import club.joylink.rtss.dao.*; +import club.joylink.rtss.dao.Map3dDataDAO; +import club.joylink.rtss.dao.MapDataDAO; +import club.joylink.rtss.dao.MapInfoDAO; import club.joylink.rtss.entity.*; +import club.joylink.rtss.exception.BaseException; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.cache.ICacheService; import club.joylink.rtss.services.simulation.SchedulingService; +import club.joylink.rtss.services.training.ITrainingV1Service; +import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; +import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.VersionUtil; import club.joylink.rtss.vo.UserVO; @@ -28,13 +28,15 @@ import club.joylink.rtss.vo.client.map.newmap.MapStationStandNewVO; import club.joylink.rtss.vo.client.runplan.RunPlanLoadVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; import java.text.Collator; import java.time.LocalDateTime; @@ -57,9 +59,6 @@ public class MapService implements IMapService { @Autowired private MapDataDAO mapDataDAO; - @Autowired - private MapVersionDAO mapVersionDAO; - @Autowired private Map3dDataDAO map3dDataDAO; @@ -198,12 +197,11 @@ public class MapService implements IMapService { @Override public PageVO queryPagedMapVersions(Long id, PageQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); - MapVersionExample versionExample = new MapVersionExample(); - versionExample.createCriteria().andMapIdEqualTo(id); - versionExample.setOrderByClause("update_time desc"); - Page page = (Page) mapVersionDAO.selectByExample(versionExample); - List mapVersionVOList = MapVersionVO.convert2VOList(page.getResult()); - return PageVO.convert(page, mapVersionVOList); + MapDataExample example = new MapDataExample(); + example.setOrderByClause("time desc"); + example.createCriteria().andMapIdEqualTo(id); + Page page = (Page) mapDataDAO.selectByExample(example); + return PageVO.convert(page, MapVersionVO.convert2VOList(page.getResult())); } @Override @@ -212,8 +210,6 @@ public class MapService implements IMapService { MapVO mapVO = this.findMapBaseInfoById(id); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapVO, String.format("id为[%s]的地图数据不存在", id)); - String version = this.findMapVersion(id); - mapVO.setVersion(version); return mapVO; } @@ -285,14 +281,16 @@ public class MapService implements IMapService { @Override public String findMapVersion(Long mapId) { - MapVersionExample example = new MapVersionExample(); - example.createCriteria().andMapIdEqualTo(mapId); - example.setOrderByClause("update_time desc"); - List versionList = this.mapVersionDAO.selectByExample(example); - if (!CollectionUtils.isEmpty(versionList)) { - return versionList.get(0).getVersion(); - } - return null; + return mapDataDAO.findVersion(mapId); + +// MapVersionExample example = new MapVersionExample(); +// example.createCriteria().andMapIdEqualTo(mapId); +// example.setOrderByClause("update_time desc"); +// List versionList = this.mapVersionDAO.selectByExample(example); +// if (!CollectionUtils.isEmpty(versionList)) { +// return versionList.get(0).getVersion(); +// } +// return null; } @Override @@ -340,8 +338,7 @@ public class MapService implements IMapService { @Override @Transactional public MapVO publish(MapVO mapVO, MapDataVO mapDataVO, UserVO userVO) { - // todo 通知课程修改城市后续处理 - // 地图信息 + //地图信息 MapInfoExample infoExample = new MapInfoExample(); infoExample.createCriteria() .andNameEqualTo(mapVO.getName()) @@ -368,46 +365,101 @@ public class MapService implements IMapService { "存在名称相同但基于不同关联城市的地图"); } } - // 地图数据 - MapDataWithBLOBs mapData; - MapDataExample dataExample = new MapDataExample(); - dataExample.createCriteria().andMapIdEqualTo(map.getId()); - List mapDataList = mapDataDAO.selectByExampleWithBLOBs(dataExample); - if (CollectionUtils.isEmpty(mapDataList)) { - mapData = new MapDataWithBLOBs(); - mapData.setMapId(map.getId()); - if (map.getDrawWay()) { - // 清除shapeData中的皮肤属性 - mapDataVO.getShapeDataNew().setSkinVO(null); - mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeDataNew())); - mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicDataNew())); - } else { - mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeData())); - mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicData())); - } - mapDataDAO.insert(mapData); + //地图数据 + MapDataWithBLOBs mapData = new MapDataWithBLOBs(); + mapData.setMapId(map.getId()); + if (map.getDrawWay()) { + // 清除shapeData中的皮肤属性 + mapDataVO.getShapeDataNew().setSkinVO(null); + mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeDataNew())); + mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicDataNew())); } else { - mapData = mapDataList.get(0); - if (map.getDrawWay()) { - mapDataVO.getShapeDataNew().setSkinVO(null); - mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeDataNew())); - mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicDataNew())); - } else { - mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeData())); - mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicData())); - } - mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData); + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("意外的老版仿真地图数据"); } - // 地图版本 - MapVersion newMapVersion = buildAndInsertMapVersion(map, userVO); + mapData.setVersion(VersionUtil.generateNext(findMapVersion(map.getId()))); + mapData.setTime(LocalDateTime.now()); + mapData.setUserId(userVO.getId()); + mapDataDAO.insert(mapData); + // 更新地图当前使用的地图数据版本 + map.setVersion(mapData.getVersion()); + mapInfoDAO.updateByPrimaryKey(map); // 保存站间运行数据 BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(map.getDrawWay()); iCacheService.remove(BusinessConsts.CachePrefix.Map + map.getId()); MapVO newMapVO = new MapVO(map); - newMapVO.setVersion(newMapVersion.getVersion()); MapDataVO dataVO = new MapDataVO(mapData, map.getDrawWay()); newMapVO.setMapData(dataVO); return newMapVO; + + +// // todo 通知课程修改城市后续处理 +// // 地图信息 +// MapInfoExample infoExample = new MapInfoExample(); +// infoExample.createCriteria() +// .andNameEqualTo(mapVO.getName()) +// .andStatusNotEqualTo(MapStatus.Delete.getCode()); +// List mapInfoList = mapInfoDAO.selectByExample(infoExample); +// MapInfo map; +// if (ObjectUtils.isEmpty(mapInfoList)) { +// map = new MapInfo(); +// map.setName(mapVO.getName()); +// map.setCityCode(mapVO.getCityCode()); +// map.setLineCode(mapVO.getLineCode()); +// map.setStatus(MapStatus.Online.getCode()); +// map.setProject(false); +// map.setDrawWay(mapVO.isDrawWay()); +// mapInfoDAO.insert(map); +// } else { +// map = mapInfoList.get(0); +// if (!MapStatus.Delete.getCode().equals(map.getStatus())) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(map.getLineCode(), mapVO.getLineCode(), +// "存在名称相同但基于不同真实线路的地图"); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(map.getDrawWay(), mapVO.isDrawWay(), +// "存在名称相同但基于不同绘制方式的地图"); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(map.getCityCode(), mapVO.getCityCode(), +// "存在名称相同但基于不同关联城市的地图"); +// } +// } +// // 地图数据 +// MapDataWithBLOBs mapData; +// MapDataExample dataExample = new MapDataExample(); +// dataExample.createCriteria().andMapIdEqualTo(map.getId()); +// List mapDataList = mapDataDAO.selectByExampleWithBLOBs(dataExample); +// if (CollectionUtils.isEmpty(mapDataList)) { +// mapData = new MapDataWithBLOBs(); +// mapData.setMapId(map.getId()); +// if (map.getDrawWay()) { +// // 清除shapeData中的皮肤属性 +// mapDataVO.getShapeDataNew().setSkinVO(null); +// mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeDataNew())); +// mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicDataNew())); +// } else { +// mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeData())); +// mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicData())); +// } +// mapDataDAO.insert(mapData); +// } else { +// mapData = mapDataList.get(0); +// if (map.getDrawWay()) { +// mapDataVO.getShapeDataNew().setSkinVO(null); +// mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeDataNew())); +// mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicDataNew())); +// } else { +// mapData.setGraphData(JsonUtils.writeValueAsString(mapDataVO.getShapeData())); +// mapData.setLogicData(JsonUtils.writeValueAsString(mapDataVO.getLogicData())); +// } +// mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData); +// } +// // 地图版本 +// MapVersion newMapVersion = buildAndInsertMapVersion(map, userVO); +// // 保存站间运行数据 +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(map.getDrawWay()); +// iCacheService.remove(BusinessConsts.CachePrefix.Map + map.getId()); +// MapVO newMapVO = new MapVO(map); +// newMapVO.setVersion(newMapVersion.getVersion()); +// MapDataVO dataVO = new MapDataVO(mapData, map.getDrawWay()); +// newMapVO.setMapData(dataVO); +// return newMapVO; } @Override @@ -449,29 +501,6 @@ public class MapService implements IMapService { } } - /** - * 创建并插入地图版本信息 - */ - private MapVersion buildAndInsertMapVersion(MapInfo map, UserVO userVO) { - String version = this.findMapVersion(map.getId()); - MapVersion newVersion = buildVersion(map, version, userVO); - mapVersionDAO.insert(newVersion); - return newVersion; - } - - /** - * 创建新的版本信息 - */ - private MapVersion buildVersion(MapInfo map, String old, UserVO userVO) { - String version = VersionUtil.generateNext(old); - MapVersion mapVersion = new MapVersion(); - mapVersion.setMapId(map.getId()); - mapVersion.setAuthorId(userVO.getId()); - mapVersion.setUpdateTime(LocalDateTime.now()); - mapVersion.setVersion(version); - return mapVersion; - } - @Override public List getMapListByLineCode(String lineCode) { MapInfoExample mapExample = new MapInfoExample(); @@ -719,6 +748,10 @@ public class MapService implements IMapService { mapInfo.setLineCode(updateVO.getLineCode()); update = true; } + if (StringUtils.hasText(updateVO.getVersion()) && versionExist(id, updateVO.getVersion())) { + mapInfo.setVersion(updateVO.getVersion()); + update = true; + } if (update) { this.mapInfoDAO.updateByPrimaryKey(mapInfo); this.iCacheService.remove(BusinessConsts.CachePrefix.Map + id); @@ -801,4 +834,14 @@ public class MapService implements IMapService { } } + + /** + * 该版本的地图数据是否存在 + */ + private boolean versionExist(Long mapId, String version) { + MapDataExample example = new MapDataExample(); + example.createCriteria().andMapIdEqualTo(mapId).andVersionEqualTo(version); + List mapData = mapDataDAO.selectByExample(example); + return !CollectionUtils.isEmpty(mapData); + } } diff --git a/src/main/java/club/joylink/rtss/services/local/LocalDataServiceImpl.java b/src/main/java/club/joylink/rtss/services/local/LocalDataServiceImpl.java index ad78ec1ad..75fdbc61d 100644 --- a/src/main/java/club/joylink/rtss/services/local/LocalDataServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/local/LocalDataServiceImpl.java @@ -55,9 +55,6 @@ public class LocalDataServiceImpl implements LocalDataService { @Autowired private MapSystemDAO mapSystemDAO; - @Autowired - private MapVersionDAO mapVersionDAO; - @Autowired private ProjectDeviceDAO projectDeviceDAO; @@ -141,12 +138,6 @@ public class LocalDataServiceImpl implements LocalDataService { .andMapIdIn(mapIdList); List ibpList = this.ibpDAO.selectByExampleWithBLOBs(ibpExample); localDataVO.setIbpList(ibpList); - // 地图版本 - MapVersionExample mapVersionExample = new MapVersionExample(); - mapVersionExample.createCriteria() - .andMapIdIn(mapIdList); - List mapVersionList = this.mapVersionDAO.selectByExample(mapVersionExample); - localDataVO.setMapVersionList(mapVersionList); // 地图系统 MapSystemExample mapSystemExample = new MapSystemExample(); mapSystemExample.createCriteria() @@ -285,10 +276,6 @@ public class LocalDataServiceImpl implements LocalDataService { if (!CollectionUtils.isEmpty(localDataVO.getProjectDeviceList())) { this.projectDeviceDAO.batchInsertWithId(localDataVO.getProjectDeviceList()); } - // 地图版本 - if (!CollectionUtils.isEmpty(localDataVO.getMapVersionList())) { - this.mapVersionDAO.batchInsertWithId(localDataVO.getMapVersionList()); - } // 地图系统 if (!CollectionUtils.isEmpty(localDataVO.getMapSystemList())) { this.mapSystemDAO.batchInsertWithId(localDataVO.getMapSystemList()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java index 7acbc511f..386ba5802 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java @@ -1,5 +1,7 @@ package club.joylink.rtss.simulation.cbtc; +import club.joylink.rtss.services.IVirtualRealityIbpService; +import club.joylink.rtss.services.completition.ICompetitionPracticalService; import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop; import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; @@ -9,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService; import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.competition.CompetitionAndScriptManager; +import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; @@ -32,9 +35,6 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO; -import club.joylink.rtss.services.IVirtualRealityIbpService; -import club.joylink.rtss.services.completition.ICompetitionPracticalService; -import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService; import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.WebSocketMessageType; import club.joylink.rtss.vo.client.factory.SocketMessageFactory; @@ -678,7 +678,7 @@ public class SimulationMainThread { Set users = simulation.getSimulationUserIds(); SocketMessageVO message = SocketMessageFactory.build( WebSocketMessageType.Simulation_Run_Plan_Reload, - simulation.getGroup(), ""); + simulation.getGroup(), "1"); this.stompMessageService.sendToUser(users, message); } diff --git a/src/main/java/club/joylink/rtss/vo/client/local/LocalDataVO.java b/src/main/java/club/joylink/rtss/vo/client/local/LocalDataVO.java index cafaba19c..1f68b8720 100644 --- a/src/main/java/club/joylink/rtss/vo/client/local/LocalDataVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/local/LocalDataVO.java @@ -27,8 +27,6 @@ public class LocalDataVO { List ibpList; - List mapVersionList; - List mapSystemList; List commandDefinitionList; diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapInfoUpdateVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapInfoUpdateVO.java index b29fabc17..25933f907 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapInfoUpdateVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapInfoUpdateVO.java @@ -20,4 +20,7 @@ public class MapInfoUpdateVO { @ApiModelProperty(value = "所属城市编码") private String cityCode; + + @ApiModelProperty("使用的地图数据的版本") + private String version; } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java index 0a3c202b9..d06757809 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapVO.java @@ -1,14 +1,14 @@ package club.joylink.rtss.vo.client.map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import club.joylink.rtss.entity.DraftMap; import club.joylink.rtss.entity.DraftMapWithBLOBs; import club.joylink.rtss.entity.MapInfo; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.MapPrdVO; import club.joylink.rtss.vo.client.map.newmap.*; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -119,6 +119,7 @@ public class MapVO { this.setProjectCode(map.getProjectCode()); this.status = map.getStatus(); this.drawWay = map.getDrawWay(); + this.version = map.getVersion(); } public static MapVO fromDraftMapEntity(DraftMapWithBLOBs draftMap) { diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapVersionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapVersionVO.java index 010e06a18..b86d34c8b 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapVersionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapVersionVO.java @@ -1,8 +1,8 @@ package club.joylink.rtss.vo.client.map; +import club.joylink.rtss.entity.MapData; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import club.joylink.rtss.entity.MapVersion; import io.swagger.annotations.ApiModel; import lombok.Getter; import lombok.Setter; @@ -24,13 +24,13 @@ public class MapVersionVO { private String version; - public MapVersionVO(MapVersion version) { - this.userId = version.getAuthorId(); - this.publishTime = version.getUpdateTime(); - this.version = version.getVersion(); + public MapVersionVO(MapData mapData) { + this.userId = mapData.getUserId(); + this.publishTime = mapData.getTime(); + this.version = mapData.getVersion(); } - public static List convert2VOList(List list) { + public static List convert2VOList(List list) { if (!CollectionUtils.isEmpty(list)) { return list.stream().map(MapVersionVO::new).collect(Collectors.toList()); } diff --git a/src/main/java/club/joylink/rtss/websocket/StompMessageService.java b/src/main/java/club/joylink/rtss/websocket/StompMessageService.java index c29143b69..acaf9d092 100644 --- a/src/main/java/club/joylink/rtss/websocket/StompMessageService.java +++ b/src/main/java/club/joylink/rtss/websocket/StompMessageService.java @@ -2,11 +2,11 @@ package club.joylink.rtss.websocket; import club.joylink.rtss.vo.client.SocketMessageVO; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.Collection; import java.util.Objects; @@ -47,7 +47,7 @@ public class StompMessageService { if (messageVO.getBody() instanceof String) { String body = (String) messageVO.getBody(); if (!body.startsWith("{") && !body.startsWith("[")) { - body = StringUtils.quote(body); + body = "\"" + body + "\""; } send = "{\"type\":\"" + messageVO.getType() + "\",\"body\":" + body + "}"; } diff --git a/src/main/resources/mybatis/mapper/MapDataDAO.xml b/src/main/resources/mybatis/mapper/MapDataDAO.xml index b7d59b52a..e40544bc5 100644 --- a/src/main/resources/mybatis/mapper/MapDataDAO.xml +++ b/src/main/resources/mybatis/mapper/MapDataDAO.xml @@ -4,6 +4,9 @@ + + + @@ -68,7 +71,7 @@ - id, map_id + id, map_id, version, `time`, user_id graph_data, logic_data @@ -138,9 +141,11 @@ - insert into map_data (map_id, graph_data, logic_data + insert into map_data (map_id, version, `time`, + user_id, graph_data, logic_data ) - values (#{mapId,jdbcType=BIGINT}, #{graphData,jdbcType=LONGVARCHAR}, #{logicData,jdbcType=LONGVARCHAR} + values (#{mapId,jdbcType=BIGINT}, #{version,jdbcType=VARCHAR}, #{time,jdbcType=TIMESTAMP}, + #{userId,jdbcType=BIGINT}, #{graphData,jdbcType=LONGVARCHAR}, #{logicData,jdbcType=LONGVARCHAR} ) @@ -149,6 +154,15 @@ map_id, + + version, + + + `time`, + + + user_id, + graph_data, @@ -160,6 +174,15 @@ #{mapId,jdbcType=BIGINT}, + + #{version,jdbcType=VARCHAR}, + + + #{time,jdbcType=TIMESTAMP}, + + + #{userId,jdbcType=BIGINT}, + #{graphData,jdbcType=LONGVARCHAR}, @@ -183,6 +206,15 @@ map_id = #{record.mapId,jdbcType=BIGINT}, + + version = #{record.version,jdbcType=VARCHAR}, + + + `time` = #{record.time,jdbcType=TIMESTAMP}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + graph_data = #{record.graphData,jdbcType=LONGVARCHAR}, @@ -198,6 +230,9 @@ update map_data set id = #{record.id,jdbcType=BIGINT}, map_id = #{record.mapId,jdbcType=BIGINT}, + version = #{record.version,jdbcType=VARCHAR}, + `time` = #{record.time,jdbcType=TIMESTAMP}, + user_id = #{record.userId,jdbcType=BIGINT}, graph_data = #{record.graphData,jdbcType=LONGVARCHAR}, logic_data = #{record.logicData,jdbcType=LONGVARCHAR} @@ -207,7 +242,10 @@ update map_data set id = #{record.id,jdbcType=BIGINT}, - map_id = #{record.mapId,jdbcType=BIGINT} + map_id = #{record.mapId,jdbcType=BIGINT}, + version = #{record.version,jdbcType=VARCHAR}, + `time` = #{record.time,jdbcType=TIMESTAMP}, + user_id = #{record.userId,jdbcType=BIGINT} @@ -218,6 +256,15 @@ map_id = #{mapId,jdbcType=BIGINT}, + + version = #{version,jdbcType=VARCHAR}, + + + `time` = #{time,jdbcType=TIMESTAMP}, + + + user_id = #{userId,jdbcType=BIGINT}, + graph_data = #{graphData,jdbcType=LONGVARCHAR}, @@ -230,13 +277,19 @@ update map_data set map_id = #{mapId,jdbcType=BIGINT}, + version = #{version,jdbcType=VARCHAR}, + `time` = #{time,jdbcType=TIMESTAMP}, + user_id = #{userId,jdbcType=BIGINT}, graph_data = #{graphData,jdbcType=LONGVARCHAR}, logic_data = #{logicData,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=BIGINT} update map_data - set map_id = #{mapId,jdbcType=BIGINT} + set map_id = #{mapId,jdbcType=BIGINT}, + version = #{version,jdbcType=VARCHAR}, + `time` = #{time,jdbcType=TIMESTAMP}, + user_id = #{userId,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT} \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/MapInfoDAO.xml b/src/main/resources/mybatis/mapper/MapInfoDAO.xml index 981f50d59..716bd25e6 100644 --- a/src/main/resources/mybatis/mapper/MapInfoDAO.xml +++ b/src/main/resources/mybatis/mapper/MapInfoDAO.xml @@ -11,6 +11,7 @@ + @@ -71,7 +72,8 @@ - id, `name`, line_code, city_code, `status`, project, project_code, draw_way, order_number + id, `name`, line_code, city_code, `status`, project, project_code, draw_way, order_number, + version @@ -210,6 +220,9 @@ order_number = #{record.orderNumber,jdbcType=INTEGER}, + + version = #{record.version,jdbcType=VARCHAR}, + @@ -225,7 +238,8 @@ project = #{record.project,jdbcType=BIT}, project_code = #{record.projectCode,jdbcType=VARCHAR}, draw_way = #{record.drawWay,jdbcType=BIT}, - order_number = #{record.orderNumber,jdbcType=INTEGER} + order_number = #{record.orderNumber,jdbcType=INTEGER}, + version = #{record.version,jdbcType=VARCHAR} @@ -257,6 +271,9 @@ order_number = #{orderNumber,jdbcType=INTEGER}, + + version = #{version,jdbcType=VARCHAR}, + where id = #{id,jdbcType=BIGINT} @@ -269,7 +286,8 @@ project = #{project,jdbcType=BIT}, project_code = #{projectCode,jdbcType=VARCHAR}, draw_way = #{drawWay,jdbcType=BIT}, - order_number = #{orderNumber,jdbcType=INTEGER} + order_number = #{orderNumber,jdbcType=INTEGER}, + version = #{version,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT} \ No newline at end of file