This commit is contained in:
xzb 2022-12-06 11:02:07 +08:00
parent 9af0490766
commit 0b72c2c16d
9 changed files with 426 additions and 18 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 80029
File Encoding : 65001
Date: 05/12/2022 09:17:49
Date: 06/12/2022 09:53:18
*/
SET NAMES utf8mb4;
@ -27,6 +27,8 @@ CREATE TABLE `rts_iscs_model_data` (
`view` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'iscs二级视图',
`place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '场所(车站、变电所、停车场等)',
`data` blob NULL COMMENT '场所整个所有的模型的数据',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

View File

@ -3,11 +3,15 @@ package club.joylink.rtss.iscs.controller;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.iscs.entity.IscsModelData;
import club.joylink.rtss.iscs.services.IscsModelDataService;
import club.joylink.rtss.iscs.vo.FindIscsModelDataBasicInfoByPageReqVo;
import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo;
import club.joylink.rtss.vo.client.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
/**
* iscs 模型数据处理接口
* <p>
@ -54,7 +58,7 @@ import org.springframework.web.bind.annotation.*;
*/
@Slf4j
@RestController
@RequestMapping("/api/v2/iscs")
@RequestMapping("/api/v2/iscs/model")
public class IscsModelDataController {
@Autowired
private IscsModelDataService modelDataService;
@ -65,7 +69,7 @@ public class IscsModelDataController {
* @param data 模型proto数据DataModelMap
*/
@PostMapping("/{system}/{view}/{place}/init")
public IscsModelDataBasicInfo storeModelData(@PathVariable("system") String system, @PathVariable("view") String view, @PathVariable("place") String place, @RequestBody byte[] data) {
public IscsModelDataBasicInfo storeModelData(@PathVariable("system") @NotNull String system, @PathVariable("view") @NotNull String view, @PathVariable("place") @NotNull String place, @RequestBody @NotNull byte[] data) {
log.debug("==>>初始化模型数据 system = {} view = {} place = {}", system, view, place);
final IscsModelData param = new IscsModelData();
param.setSystem(system);
@ -82,7 +86,7 @@ public class IscsModelDataController {
*/
@GetMapping("/{system}/{view}/{place}")
@ResponseBody
public byte[] findModelData(@PathVariable("system") String system, @PathVariable("view") String view, @PathVariable("place") String place) {
public byte[] findModelDataByBasicInfo(@PathVariable("system") @NotNull String system, @PathVariable("view") @NotNull String view, @PathVariable("place") @NotNull String place) {
log.debug("==>>获取模型数据 system = {} view = {} place = {}", system, view, place);
final IscsModelDataBasicInfo param = new IscsModelDataBasicInfo();
param.setSystem(system);
@ -92,5 +96,25 @@ public class IscsModelDataController {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rt && null != rt.getData(), "模型数据不存在");
return rt.getData();
}
/**
* 获取模型数据
*
* @return 模型proto数据DataModelMap
*/
@GetMapping("/{id}")
@ResponseBody
public byte[] findModelDataById(@PathVariable("id") @NotNull Long id) {
log.debug("==>>获取模型数据 id = {}", id);
final IscsModelData rt = modelDataService.findModelData(id);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rt && null != rt.getData(), "模型数据不存在");
return rt.getData();
}
/**
* 分页查询ISCS模型数据基本信息
*/
@PostMapping("/find/page")
public PageVO<IscsModelDataBasicInfo> findModelDataByPage(@RequestBody FindIscsModelDataBasicInfoByPageReqVo req) {
log.debug("==>>分页查询ISCS模型数据基本信息 : {}", req.toString());
return modelDataService.findModelDataByPage(req);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.iscs.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
@ -29,6 +30,16 @@ public class IscsModelData implements Serializable {
*/
private String place;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 场所整个所有的模型的数据
*/

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.iscs.entity;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -393,6 +394,126 @@ public class IscsModelDataExample {
addCriterion("place not between", value1, value2, "place");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(LocalDateTime value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(LocalDateTime value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(LocalDateTime value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(LocalDateTime value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(LocalDateTime value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<LocalDateTime> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<LocalDateTime> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
/**

View File

@ -4,12 +4,21 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.iscs.dao.IscsModelDataDAO;
import club.joylink.rtss.iscs.entity.IscsModelData;
import club.joylink.rtss.iscs.entity.IscsModelDataExample;
import club.joylink.rtss.iscs.vo.FindIscsModelDataBasicInfoByPageReqVo;
import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo;
import club.joylink.rtss.vo.client.PageVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
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.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class IscsModelDataService {
@ -22,15 +31,18 @@ public class IscsModelDataService {
@Transactional(readOnly = false, rollbackFor = Exception.class)
public IscsModelDataBasicInfo storeModelData(final IscsModelData md) {
//参数校验
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(),"参数校验失败");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(), "参数校验失败");
//
IscsModelData has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
IscsModelData has = findBasicBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
final LocalDateTime now = LocalDateTime.now();
md.setUpdateTime(now);
if (null != has) {//更新
md.setId(has.getId());
md.setCreateTime(now);
modelDataDao.updateByPrimaryKeySelective(md);
} else {//新增
modelDataDao.insertSelective(md);
has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
has = findBasicBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
}
//
IscsModelDataBasicInfo rt = new IscsModelDataBasicInfo();
@ -42,23 +54,114 @@ public class IscsModelDataService {
}
/**
* 根据完整基本模型信息获取模型数据
* 根据完整基本模型信息获取模型数据(包括大字段信息)
*/
@Transactional(readOnly = true, rollbackFor = Exception.class)
@Transactional(readOnly = true)
public IscsModelData findModelData(final IscsModelDataBasicInfo md) {
//参数校验
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(),"参数校验失败");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(), "参数校验失败");
//
return findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
return findAllBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
}
/**
* 根据完整基本模型信息获取模型数据(包括大字段信息)
*/
@Transactional(readOnly = true)
public IscsModelData findModelData(final Long id) {
return modelDataDao.selectByPrimaryKey(id);
}
/**
* 分页查询ISCS模型数据基本信息
*/
@Transactional(readOnly = true)
public PageVO<IscsModelDataBasicInfo> findModelDataByPage(FindIscsModelDataBasicInfoByPageReqVo req) {
IscsModelDataExample example = new IscsModelDataExample();
if (req.getLogicAnd()) {
final IscsModelDataExample.Criteria andCriteria = example.createCriteria();
if (StringUtils.hasText(req.getSystem())) {
if (req.getLike()) {
andCriteria.andSystemLike(String.format("%%%s%%", req.getSystem()));
} else {
andCriteria.andSystemEqualTo(req.getSystem());
}
}
if (StringUtils.hasText(req.getView())) {
if (req.getLike()) {
andCriteria.andViewLike(String.format("%%%s%%", req.getView()));
} else {
andCriteria.andViewEqualTo(req.getView());
}
}
if (StringUtils.hasText(req.getPlace())) {
if (req.getLike()) {
andCriteria.andPlaceLike(String.format("%%%s%%", req.getPlace()));
} else {
andCriteria.andPlaceEqualTo(req.getPlace());
}
}
} else {
if (StringUtils.hasText(req.getSystem())) {
if (req.getLike()) {
example.or().andSystemLike(String.format("%%%s%%", req.getSystem()));
} else {
example.or().andSystemEqualTo(req.getSystem());
}
}
if (StringUtils.hasText(req.getView())) {
if (req.getLike()) {
example.or().andViewLike(String.format("%%%s%%", req.getView()));
} else {
example.or().andViewEqualTo(req.getView());
}
}
if (StringUtils.hasText(req.getPlace())) {
if (req.getLike()) {
example.or().andPlaceLike(String.format("%%%s%%", req.getPlace()));
} else {
example.or().andPlaceEqualTo(req.getPlace());
}
}
}
//
final String orderBy = req.getOrderByType().with() + (req.getDesc() ? " desc" : "");
PageHelper.clearPage();
PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy);
Page<IscsModelData> sqlPage = (Page<IscsModelData>) this.modelDataDao.selectByExample(example);
List<IscsModelDataBasicInfo> rtList = new ArrayList<>();
if (!CollectionUtils.isEmpty(sqlPage.getResult())) {
rtList = sqlPage.getResult().stream().map((IscsModelData md) -> {
final IscsModelDataBasicInfo bi = new IscsModelDataBasicInfo();
bi.setId(md.getId());
bi.setSystem(md.getSystem());
bi.setView(md.getView());
bi.setPlace(md.getPlace());
bi.setCreateTime(md.getCreateTime());
bi.setUpdateTime(md.getUpdateTime());
return bi;
}).collect(Collectors.toList());
}
return PageVO.convert(sqlPage, rtList);
}
/**
* 根据基本信息查询模型(不包括大字段信息)
*/
private IscsModelData findBySystemViewAndPlace(String system, String view, String place) {
private IscsModelData findBasicBySystemViewAndPlace(String system, String view, String place) {
IscsModelDataExample example = new IscsModelDataExample();
example.createCriteria().andSystemEqualTo(system).andViewEqualTo(view).andPlaceEqualTo(place);
List<IscsModelData> list = modelDataDao.selectByExample(example);
return null != list && list.size() > 0 ? list.get(0) : null;
}
/**
* 根据基本信息查询模型(包括大字段信息)
*/
private IscsModelData findAllBySystemViewAndPlace(String system, String view, String place) {
IscsModelDataExample example = new IscsModelDataExample();
example.createCriteria().andSystemEqualTo(system).andViewEqualTo(view).andPlaceEqualTo(place);
List<IscsModelData> list = modelDataDao.selectByExampleWithBLOBs(example);
return null != list && list.size() > 0 ? list.get(0) : null;
}
}

View File

@ -0,0 +1,91 @@
package club.joylink.rtss.iscs.vo;
import club.joylink.rtss.vo.client.PageQueryVO;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* 分页查询ISCS模型数据基本信息
*/
@Data
public class FindIscsModelDataBasicInfoByPageReqVo extends PageQueryVO {
/**
* iscs一级系统(如FASPISAFC等)
*/
private String system;
/**
* iscs二级视图
*/
private String view;
/**
* 场所(车站变电所停车场等)
*/
private String place;
/**
* 当查询条件有多个时条件间关系true-false-默认值为true
*/
private Boolean logicAnd = true;
/**
* 默认true,true-模糊查询false-精确查询
*/
private Boolean like = true;
/**
* 是否降序true-降序false-升序默认值为true;
*/
private Boolean desc = true;
/**
* 排序类型,默认按创建时间排序序列化为数值1-system2-view3-place4-create_time ,5-update_time
*/
private OrderByType orderByType = OrderByType.OrderByCreateTime;
/////////////////////////////////////////////
public static enum OrderByType {
OrderBySystem(1, "system"),
OrderByView(2, "view"),
OrderByPlace(3, "place"),
OrderByCreateTime(4, "create_time"),
OrderByUpdateTime(5, "update_time"),
;
private Integer value;
private String orderBy;
private OrderByType(Integer value, String orderBy) {
this.value = value;
this.orderBy = orderBy;
}
public String with() {
return this.orderBy;
}
@JsonCreator
public static OrderByType getItem(Integer value) {
return map.get(value);
}
@JsonValue
public Integer getValue() {
return this.value;
}
private static Map<Integer, OrderByType> map = new HashMap<>();
static {
for (OrderByType t : values()) {
map.put(t.value, t);
}
}
}
@Override
public String toString() {
return
"system='" + system + '\'' +
", view='" + view + '\'' +
", place='" + place + '\'' + super.toString();
}
}

View File

@ -2,6 +2,11 @@ package club.joylink.rtss.iscs.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 模型数据基本信息
*/
@Data
public class IscsModelDataBasicInfo {
/**
@ -20,4 +25,13 @@ public class IscsModelDataBasicInfo {
* 场所(车站变电所停车场等)
*/
private String place;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
}

View File

@ -31,4 +31,10 @@ public class PageQueryVO {
this.pageSize = pageSize;
}
@Override
public String toString() {
return
" pageNum=" + pageNum +
", pageSize=" + pageSize;
}
}

View File

@ -6,6 +6,8 @@
<result column="system" jdbcType="VARCHAR" property="system" />
<result column="view" jdbcType="VARCHAR" property="view" />
<result column="place" jdbcType="VARCHAR" property="place" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.iscs.entity.IscsModelData">
<result column="data" jdbcType="LONGVARBINARY" property="data" />
@ -69,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `system`, `view`, place
id, `system`, `view`, place, create_time, update_time
</sql>
<sql id="Blob_Column_List">
`data`
@ -140,9 +142,11 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
insert into rts_iscs_model_data (id, `system`, `view`,
place, `data`)
place, create_time, update_time,
`data`)
values (#{id,jdbcType=BIGINT}, #{system,jdbcType=VARCHAR}, #{view,jdbcType=VARCHAR},
#{place,jdbcType=VARCHAR}, #{data,jdbcType=LONGVARBINARY})
#{place,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{data,jdbcType=LONGVARBINARY})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
insert into rts_iscs_model_data
@ -159,6 +163,12 @@
<if test="place != null">
place,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="data != null">
`data`,
</if>
@ -176,6 +186,12 @@
<if test="place != null">
#{place,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="data != null">
#{data,jdbcType=LONGVARBINARY},
</if>
@ -202,6 +218,12 @@
<if test="record.place != null">
place = #{record.place,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.data != null">
`data` = #{record.data,jdbcType=LONGVARBINARY},
</if>
@ -216,6 +238,8 @@
`system` = #{record.system,jdbcType=VARCHAR},
`view` = #{record.view,jdbcType=VARCHAR},
place = #{record.place,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`data` = #{record.data,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -226,7 +250,9 @@
set id = #{record.id,jdbcType=BIGINT},
`system` = #{record.system,jdbcType=VARCHAR},
`view` = #{record.view,jdbcType=VARCHAR},
place = #{record.place,jdbcType=VARCHAR}
place = #{record.place,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -243,6 +269,12 @@
<if test="place != null">
place = #{place,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="data != null">
`data` = #{data,jdbcType=LONGVARBINARY},
</if>
@ -254,6 +286,8 @@
set `system` = #{system,jdbcType=VARCHAR},
`view` = #{view,jdbcType=VARCHAR},
place = #{place,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
`data` = #{data,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=BIGINT}
</update>
@ -261,7 +295,9 @@
update rts_iscs_model_data
set `system` = #{system,jdbcType=VARCHAR},
`view` = #{view,jdbcType=VARCHAR},
place = #{place,jdbcType=VARCHAR}
place = #{place,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>