From 250de1dc73adc1e234f927f28200ee295dc1cb38 Mon Sep 17 00:00:00 2001 From: DU Date: Mon, 12 Apr 2021 18:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=BD=92?= =?UTF-8?q?=E7=B1=BB=EF=BC=8Chuawei=E8=AF=AD=E9=9F=B3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 36 +- .../rtss/constants/BusinessConsts.java | 4 + .../publish/MapGroupController.java | 62 +++ .../controller/voice/VoiceController.java | 30 ++ .../club/joylink/rtss/dao/MapGroupDAO.java | 27 + .../club/joylink/rtss/entity/MapGroup.java | 95 ++++ .../joylink/rtss/entity/MapGroupExample.java | 492 ++++++++++++++++++ .../rtss/services/IMapGroupService.java | 28 + .../rtss/services/MapGroupService.java | 104 ++++ .../joylink/rtss/services/MapService.java | 1 + .../joylink/rtss/services/ReleaseService.java | 5 +- .../voice/huawei/HuaweiVoiceServiceImpl.java | 134 +++-- .../joylink/rtss/vo/client/ReleaseVO.java | 5 + .../rtss/vo/client/map/MapGroupQueryVO.java | 18 + .../rtss/vo/client/map/MapGroupVO.java | 59 +++ .../resources/mybatis/mapper/MapGroupDAO.xml | 198 +++++++ 16 files changed, 1208 insertions(+), 90 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/controller/publish/MapGroupController.java create mode 100644 src/main/java/club/joylink/rtss/controller/voice/VoiceController.java create mode 100644 src/main/java/club/joylink/rtss/dao/MapGroupDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/MapGroup.java create mode 100644 src/main/java/club/joylink/rtss/entity/MapGroupExample.java create mode 100644 src/main/java/club/joylink/rtss/services/IMapGroupService.java create mode 100644 src/main/java/club/joylink/rtss/services/MapGroupService.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/map/MapGroupQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/map/MapGroupVO.java create mode 100644 src/main/resources/mybatis/mapper/MapGroupDAO.xml diff --git a/pom.xml b/pom.xml index 0e2488f30..8d357e4a2 100644 --- a/pom.xml +++ b/pom.xml @@ -108,27 +108,27 @@ 0.2.1 - - - - - + + com.huawei.sis + huaweicloud-java-sdk-sis + 1.3.2 + - - - - - - - - - - - - - + + + sis-repo + Sis Release Repository + https://mirrors.huaweicloud.com/repository/maven/huaweicloudsdk + + true + + + false + + + diff --git a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java index f0e0e5c38..35854ac53 100644 --- a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java +++ b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java @@ -796,4 +796,8 @@ public interface BusinessConsts { String VALID = "1"; } } + + enum MapGroupType{ + DATA,RUNPLAN; + } } diff --git a/src/main/java/club/joylink/rtss/controller/publish/MapGroupController.java b/src/main/java/club/joylink/rtss/controller/publish/MapGroupController.java new file mode 100644 index 000000000..156ca0522 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/publish/MapGroupController.java @@ -0,0 +1,62 @@ +package club.joylink.rtss.controller.publish; + +import club.joylink.rtss.services.IMapGroupService; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.ReleaseVO; +import club.joylink.rtss.vo.client.map.MapGroupQueryVO; +import club.joylink.rtss.vo.client.map.MapGroupVO; +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 java.util.List; + +@Api(tags = {"地图数据组管理"}) +@RestController +@RequestMapping("/api/mapGroup") +public class MapGroupController { + + @Autowired + private IMapGroupService iMapGroupService; + + @ApiOperation(value = "添加地图数据组") + @PostMapping(path = "") + public void createMapGroup(@RequestBody @Validated MapGroupVO mapGroupVO) { + this.iMapGroupService.create(mapGroupVO); + } + + @ApiOperation(value = "修改地图数据组") + @PutMapping(path = "{groupId}") + public void updateMapGroup(@PathVariable Long groupId, @RequestBody @Validated MapGroupVO mapGroupVO) { + this.iMapGroupService.update(groupId, mapGroupVO); + } + + @ApiOperation(value = "地图数据组关联地图") + @PutMapping(path = "{groupId}/ref/map/{mapId}") + public void refMap2Group(@PathVariable Long groupId, @PathVariable Long mapId) { + this.iMapGroupService.relMap2Group(groupId, mapId); + } + + @ApiOperation(value = "删除地图数据组") + @DeleteMapping(path = "{groupId}") + public void deleteMapGroup(@PathVariable Long groupId) { + this.iMapGroupService.delete(groupId); + } + + @ApiOperation(value = "分页获取所有地图数据组") + @GetMapping(path = "page") + public PageVO getPageMapGroups(MapGroupQueryVO queryVO) { + return this.iMapGroupService.getPage(queryVO); + } + + + @ApiOperation("同步导入地图相关数据") + @PutMapping("/syc/import") + public void importFromJson(@RequestBody ReleaseVO json, @RequestAttribute UserVO user) { + iMapGroupService.syncImportMapData(json, user); + } + +} diff --git a/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java b/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java new file mode 100644 index 000000000..412649ba8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java @@ -0,0 +1,30 @@ +package club.joylink.rtss.controller.voice; + +import club.joylink.rtss.services.IVoiceService; +import club.joylink.rtss.vo.client.VoiceRecognitionResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +@Api("语音AI接口") +@RestController +@RequestMapping("/api/voice") +public class VoiceController { + + + @Autowired + @Qualifier("HuaWeiVoiceService") + private IVoiceService iVoiceService; + + @ApiOperation("语音识别") + @PostMapping("recognition") + public VoiceRecognitionResult voiceRecognition(MultipartFile file) { + return this.iVoiceService.voiceRecognition(file, ""); + } + +} diff --git a/src/main/java/club/joylink/rtss/dao/MapGroupDAO.java b/src/main/java/club/joylink/rtss/dao/MapGroupDAO.java new file mode 100644 index 000000000..51e3a8a66 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/MapGroupDAO.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.MapGroup; +import club.joylink.rtss.entity.MapGroupExample; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +/** + * MapGroupDAO继承基类 + */ +@Repository +public interface MapGroupDAO extends MyBatisBaseDao { + + @Select("SELECT\n" + "*\n" + "FROM\n" + + "map_group\n" + + "WHERE\n" + + "group_type = #{type}\n" + + "AND\n" + + "(map_ids LIKE CONCAT('[',#{mapId},',%')\n" + + "OR\n" + + "map_ids LIKE CONCAT('%,',#{mapId},']')\n" + + "OR\n" + + "map_ids LIKE CONCAT('%,',#{mapId},',%'))\n" + + "LIMIT 1") + MapGroup findEntityByMapId(String type,Long mapId); + +} diff --git a/src/main/java/club/joylink/rtss/entity/MapGroup.java b/src/main/java/club/joylink/rtss/entity/MapGroup.java new file mode 100644 index 000000000..a2aa864e4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/MapGroup.java @@ -0,0 +1,95 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; + +/** + * map_group + * @author + */ +public class MapGroup implements Serializable { + private Long id; + + private String groupName; + + private String groupType; + + private String mapIds; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupType() { + return groupType; + } + + public void setGroupType(String groupType) { + this.groupType = groupType; + } + + public String getMapIds() { + return mapIds; + } + + public void setMapIds(String mapIds) { + this.mapIds = mapIds; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + MapGroup other = (MapGroup) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getGroupName() == null ? other.getGroupName() == null : this.getGroupName().equals(other.getGroupName())) + && (this.getGroupType() == null ? other.getGroupType() == null : this.getGroupType().equals(other.getGroupType())) + && (this.getMapIds() == null ? other.getMapIds() == null : this.getMapIds().equals(other.getMapIds())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getGroupName() == null) ? 0 : getGroupName().hashCode()); + result = prime * result + ((getGroupType() == null) ? 0 : getGroupType().hashCode()); + result = prime * result + ((getMapIds() == null) ? 0 : getMapIds().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(", groupName=").append(groupName); + sb.append(", groupType=").append(groupType); + sb.append(", mapIds=").append(mapIds); + 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/MapGroupExample.java b/src/main/java/club/joylink/rtss/entity/MapGroupExample.java new file mode 100644 index 000000000..cb4a3e30c --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/MapGroupExample.java @@ -0,0 +1,492 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class MapGroupExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public MapGroupExample() { + 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 andGroupNameIsNull() { + addCriterion("group_name is null"); + return (Criteria) this; + } + + public Criteria andGroupNameIsNotNull() { + addCriterion("group_name is not null"); + return (Criteria) this; + } + + public Criteria andGroupNameEqualTo(String value) { + addCriterion("group_name =", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameNotEqualTo(String value) { + addCriterion("group_name <>", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameGreaterThan(String value) { + addCriterion("group_name >", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameGreaterThanOrEqualTo(String value) { + addCriterion("group_name >=", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameLessThan(String value) { + addCriterion("group_name <", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameLessThanOrEqualTo(String value) { + addCriterion("group_name <=", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameLike(String value) { + addCriterion("group_name like", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameNotLike(String value) { + addCriterion("group_name not like", value, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameIn(List values) { + addCriterion("group_name in", values, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameNotIn(List values) { + addCriterion("group_name not in", values, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameBetween(String value1, String value2) { + addCriterion("group_name between", value1, value2, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupNameNotBetween(String value1, String value2) { + addCriterion("group_name not between", value1, value2, "groupName"); + return (Criteria) this; + } + + public Criteria andGroupTypeIsNull() { + addCriterion("group_type is null"); + return (Criteria) this; + } + + public Criteria andGroupTypeIsNotNull() { + addCriterion("group_type is not null"); + return (Criteria) this; + } + + public Criteria andGroupTypeEqualTo(String value) { + addCriterion("group_type =", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeNotEqualTo(String value) { + addCriterion("group_type <>", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeGreaterThan(String value) { + addCriterion("group_type >", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeGreaterThanOrEqualTo(String value) { + addCriterion("group_type >=", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeLessThan(String value) { + addCriterion("group_type <", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeLessThanOrEqualTo(String value) { + addCriterion("group_type <=", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeLike(String value) { + addCriterion("group_type like", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeNotLike(String value) { + addCriterion("group_type not like", value, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeIn(List values) { + addCriterion("group_type in", values, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeNotIn(List values) { + addCriterion("group_type not in", values, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeBetween(String value1, String value2) { + addCriterion("group_type between", value1, value2, "groupType"); + return (Criteria) this; + } + + public Criteria andGroupTypeNotBetween(String value1, String value2) { + addCriterion("group_type not between", value1, value2, "groupType"); + return (Criteria) this; + } + + public Criteria andMapIdsIsNull() { + addCriterion("map_ids is null"); + return (Criteria) this; + } + + public Criteria andMapIdsIsNotNull() { + addCriterion("map_ids is not null"); + return (Criteria) this; + } + + public Criteria andMapIdsEqualTo(String value) { + addCriterion("map_ids =", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsNotEqualTo(String value) { + addCriterion("map_ids <>", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsGreaterThan(String value) { + addCriterion("map_ids >", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsGreaterThanOrEqualTo(String value) { + addCriterion("map_ids >=", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsLessThan(String value) { + addCriterion("map_ids <", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsLessThanOrEqualTo(String value) { + addCriterion("map_ids <=", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsLike(String value) { + addCriterion("map_ids like", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsNotLike(String value) { + addCriterion("map_ids not like", value, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsIn(List values) { + addCriterion("map_ids in", values, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsNotIn(List values) { + addCriterion("map_ids not in", values, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsBetween(String value1, String value2) { + addCriterion("map_ids between", value1, value2, "mapIds"); + return (Criteria) this; + } + + public Criteria andMapIdsNotBetween(String value1, String value2) { + addCriterion("map_ids not between", value1, value2, "mapIds"); + 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/IMapGroupService.java b/src/main/java/club/joylink/rtss/services/IMapGroupService.java new file mode 100644 index 000000000..0a645c81d --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/IMapGroupService.java @@ -0,0 +1,28 @@ +package club.joylink.rtss.services; + +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.ReleaseVO; +import club.joylink.rtss.vo.client.map.MapGroupQueryVO; +import club.joylink.rtss.vo.client.map.MapGroupVO; + +import java.util.List; + +public interface IMapGroupService { + void create(MapGroupVO mapGroupVO); + + void update(Long id, MapGroupVO mapGroupVO); + + void relMap2Group(Long id, Long mapId); + + MapGroupVO getMapGroupByMapId(Long mapId, BusinessConsts.MapGroupType type); + + void delete(Long id); + + List getAll(); + + PageVO getPage(MapGroupQueryVO queryVO); + + void syncImportMapData(ReleaseVO releaseVO, UserVO user); +} diff --git a/src/main/java/club/joylink/rtss/services/MapGroupService.java b/src/main/java/club/joylink/rtss/services/MapGroupService.java new file mode 100644 index 000000000..77d213f3e --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/MapGroupService.java @@ -0,0 +1,104 @@ +package club.joylink.rtss.services; + +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.dao.MapGroupDAO; +import club.joylink.rtss.entity.MapGroup; +import club.joylink.rtss.entity.MapGroupExample; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.ReleaseVO; +import club.joylink.rtss.vo.client.map.MapGroupQueryVO; +import club.joylink.rtss.vo.client.map.MapGroupVO; +import club.joylink.rtss.vo.client.map.RealLineListVO; +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.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Objects; + +@Service +public class MapGroupService implements IMapGroupService { + + @Autowired + private MapGroupDAO mapGroupDAO; + + @Autowired + private IReleaseService iReleaseService; + + + @Override + public void create(MapGroupVO mapGroupVO) { + MapGroup mapGroup = mapGroupVO.convert2DB(); + this.mapGroupDAO.insert(mapGroup); + } + + @Override + public void update(Long id, MapGroupVO mapGroupVO) { + MapGroup mapGroup = mapGroupVO.convert2DB(); + mapGroup.setId(id); + this.mapGroupDAO.updateByPrimaryKey(mapGroup); + } + + @Override + public void relMap2Group(Long id, Long mapId) { + MapGroup mapGroup = mapGroupDAO.selectByPrimaryKey(id); + List o = JsonUtils.readCollection(mapGroup.getMapIds(), List.class, Long.class); + mapGroup.setMapIds(JsonUtils.writeValueAsString(o.add(mapId))); + this.mapGroupDAO.updateByPrimaryKey(mapGroup); + } + + @Override + public MapGroupVO getMapGroupByMapId(Long mapId, BusinessConsts.MapGroupType type) { + MapGroup mapGroup = mapGroupDAO.findEntityByMapId(type.name(), mapId); + if (Objects.isNull(mapGroup)) return null; + return new MapGroupVO(mapGroup); + } + + @Override + public void delete(Long id) { + this.mapGroupDAO.deleteByPrimaryKey(id); + } + + @Override + public List getAll() { + MapGroupExample e = new MapGroupExample(); + List mapGroups = this.mapGroupDAO.selectByExample(e); + return MapGroupVO.convert2VOList(mapGroups); + + } + + @Override + public PageVO getPage(MapGroupQueryVO queryVO) { + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + MapGroupExample e = new MapGroupExample(); + MapGroupExample.Criteria criteria = e.createCriteria(); + if (StringUtils.hasText(queryVO.getName())) { + criteria.andGroupNameLike(String.format("%%%s%%", queryVO.getName())); + } + if (Objects.nonNull(queryVO.getType())) { + criteria.andGroupTypeEqualTo(queryVO.getType().name()); + } + Page page = (Page) this.mapGroupDAO.selectByExample(e); + return PageVO.convert(page, MapGroupVO.convert2VOList(page.getResult())); + + } + + @Override + public void syncImportMapData(ReleaseVO releaseVO, UserVO user) { + MapGroupVO mapGroup = getMapGroupByMapId(releaseVO.getMapId(), BusinessConsts.MapGroupType.DATA); + if (Objects.isNull(mapGroup) || CollectionUtils.isEmpty(mapGroup.getMapIds())) { + return; + } + mapGroup.getMapIds().forEach(mapId -> { + if (Objects.equals(mapId, releaseVO.getMapId())) return; + + iReleaseService.importFromJson(releaseVO.getMapId(), releaseVO, user); + + }); + } +} diff --git a/src/main/java/club/joylink/rtss/services/MapService.java b/src/main/java/club/joylink/rtss/services/MapService.java index c04a6f023..4c6a45447 100644 --- a/src/main/java/club/joylink/rtss/services/MapService.java +++ b/src/main/java/club/joylink/rtss/services/MapService.java @@ -160,6 +160,7 @@ public class MapService implements IMapService { return MapVO.convert2VOList(list); } + @Override public List listOnline() { MapInfoExample example = new MapInfoExample(); MapInfoExample.Criteria criteria = example.createCriteria(); diff --git a/src/main/java/club/joylink/rtss/services/ReleaseService.java b/src/main/java/club/joylink/rtss/services/ReleaseService.java index 78307f6ff..e281f2289 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseService.java @@ -69,7 +69,8 @@ public class ReleaseService implements IReleaseService { @Override public ReleaseVO exportAsJson(Long mapId, ReleaseConfigVO config) { - ReleaseVO releaseVO = new ReleaseVO(); + ReleaseVO releaseVO = new ReleaseVO(mapId); + MapVO mapInfo = iMapService.getMapInfoById(mapId); //地图数据强制选择 releaseVO.setMapData(getMapDataWithBLOBs(mapId, mapInfo.getVersion())); @@ -163,12 +164,14 @@ public class ReleaseService implements IReleaseService { return releaseVO; } + @Transactional @Override public void importFromJson(Long mapId, ReleaseVO releaseVO, UserVO user) { BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(releaseVO.getMapData()); BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(releaseVO.getRealLineConfig()); + MapVO selectedMapInfo = iMapService.getMapInfoById(mapId); BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(Objects.equals(selectedMapInfo.getLineCode(), releaseVO.getRealLineConfig().getCode())); diff --git a/src/main/java/club/joylink/rtss/services/voice/huawei/HuaweiVoiceServiceImpl.java b/src/main/java/club/joylink/rtss/services/voice/huawei/HuaweiVoiceServiceImpl.java index a04f5301d..377bb1283 100644 --- a/src/main/java/club/joylink/rtss/services/voice/huawei/HuaweiVoiceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/voice/huawei/HuaweiVoiceServiceImpl.java @@ -1,71 +1,63 @@ -//package club.joylink.rtss.services.voice.huawei; -// -//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -//import club.joylink.rtss.services.IVoiceService; -//import club.joylink.rtss.services.voice.baidu.AsrService; -//import club.joylink.rtss.services.voice.baidu.TokenHolder; -//import club.joylink.rtss.services.voice.baidu.TtsService; -//import club.joylink.rtss.services.voice.baidu.VoiceAsrResult; -//import club.joylink.rtss.vo.client.VoiceRecognitionResult; -//import com.huawei.sis.bean.AuthInfo; -//import com.huawei.sis.bean.SisConfig; -//import com.huawei.sis.bean.request.AsrCustomShortRequest; -//import com.huawei.sis.bean.response.AsrCustomShortResponse; -//import com.huawei.sis.client.AsrCustomizationClient; -//import com.huawei.sis.exception.SisException; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Service; -//import org.springframework.web.client.RestTemplate; -//import org.springframework.web.multipart.MultipartFile; -// -//import java.io.ByteArrayInputStream; -//import java.io.IOException; -//import java.io.InputStream; -//import java.util.Base64; -// -//@Slf4j -//@Service("HuaweiVoiceService") -//public class HuaweiVoiceServiceImpl implements IVoiceService { -// -// /** -// * 华为语音识别配置 -// */ -// private final String ak = "YDUXTXRYGAHGPHAIXZCU"; -// private final String sk = "Kcbm3sTDCYEou8kGeAhKxfBkgWybIn6IjJyGBX3p"; -// private final String region = "cn-north-4"; -// private final String projectId = "0aada8176180f28c2f34c0196f5394e8"; -// -// -// @Override -// public String synthesis(String message, String per) { -// throw BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.exception("功能暂未实现"); -// } -// -// @Override -// public VoiceRecognitionResult voiceRecognition(MultipartFile file, String lang) { -// String filePath; -// try { -// filePath = IVoiceService.handleAndSaveFile(file); -// } catch (IOException e) { -// throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音文件上传失败", e); -// } -// AuthInfo authInfo = new AuthInfo(ak, sk, region, projectId); -// SisConfig sisConfig = new SisConfig(); -// AsrCustomizationClient client = new AsrCustomizationClient(authInfo, sisConfig); -// String data; -// try { -// data = Base64.getEncoder().encodeToString(file.getBytes()); -// } catch (IOException e) { -// throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音文件编码失败", e); -// } -// try { -// AsrCustomShortRequest request = new AsrCustomShortRequest(data, "pcm16k16bit", "chinese_16k_common"); -// AsrCustomShortResponse response = client.getAsrShortResponse(request); -// return new VoiceRecognitionResult(filePath, response.getResult().getText()); -// } catch (SisException e) { -// throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音识别失败", e); -// } -// } -// -//} +package club.joylink.rtss.services.voice.huawei; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.IVoiceService; +import club.joylink.rtss.vo.client.VoiceRecognitionResult; +import com.huawei.sis.bean.AuthInfo; +import com.huawei.sis.bean.SisConfig; +import com.huawei.sis.bean.request.AsrCustomShortRequest; +import com.huawei.sis.bean.response.AsrCustomShortResponse; +import com.huawei.sis.client.AsrCustomizationClient; +import com.huawei.sis.exception.SisException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Base64; + +@Slf4j +@Service("HuaWeiVoiceService") +public class HuaweiVoiceServiceImpl implements IVoiceService { + + /** + * 华为语音识别配置 + */ + private final String ak = "YDUXTXRYGAHGPHAIXZCU"; + private final String sk = "Kcbm3sTDCYEou8kGeAhKxfBkgWybIn6IjJyGBX3p"; + private final String region = "cn-north-4"; + private final String projectId = "0aada8176180f28c2f34c0196f5394e8"; + + + @Override + public String synthesis(String message, String per) { + throw BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.exception("功能暂未实现"); + } + + @Override + public VoiceRecognitionResult voiceRecognition(MultipartFile file, String lang) { + String filePath; + try { + filePath = IVoiceService.handleAndSaveFile(file); + } catch (IOException e) { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音文件上传失败", e); + } + AuthInfo authInfo = new AuthInfo(ak, sk, region, projectId); + SisConfig sisConfig = new SisConfig(); + AsrCustomizationClient client = new AsrCustomizationClient(authInfo, sisConfig); + String data; + try { + data = Base64.getEncoder().encodeToString(file.getBytes()); + } catch (IOException e) { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音文件编码失败", e); + } + try { + AsrCustomShortRequest request = new AsrCustomShortRequest(data, "pcm16k16bit", "chinese_16k_common"); + AsrCustomShortResponse response = client.getAsrShortResponse(request); + return new VoiceRecognitionResult(filePath, response.getResult().getText()); + } catch (SisException e) { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音识别失败", e); + } + } + +} diff --git a/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java b/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java index 75d725c00..4589397a7 100644 --- a/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/ReleaseVO.java @@ -11,6 +11,8 @@ import java.util.List; @Setter @NoArgsConstructor public class ReleaseVO { + + private Long mapId; /** * 地图数据 */ @@ -60,4 +62,7 @@ public class ReleaseVO { private List competitions; + public ReleaseVO(Long mapId) { + this.mapId = mapId; + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapGroupQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapGroupQueryVO.java new file mode 100644 index 000000000..d5724fce2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapGroupQueryVO.java @@ -0,0 +1,18 @@ +package club.joylink.rtss.vo.client.map; + +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.vo.client.PageQueryVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class MapGroupQueryVO extends PageQueryVO { + + private String name; + + private BusinessConsts.MapGroupType type; + +} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapGroupVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapGroupVO.java new file mode 100644 index 000000000..1d9f63ab6 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/map/MapGroupVO.java @@ -0,0 +1,59 @@ +package club.joylink.rtss.vo.client.map; + +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.entity.MapGroup; +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.util.CollectionUtils; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "地图数据组VO") +@Getter +@Setter +@NoArgsConstructor +public class MapGroupVO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @NotBlank(message = "组名不能为空") + private String name; + + @NotNull(message = "分组类型不能为空") + private BusinessConsts.MapGroupType type; + + private List mapIds; + + public MapGroupVO(MapGroup mapGroup) { + id = mapGroup.getId(); + name = mapGroup.getGroupName(); + type = BusinessConsts.MapGroupType.valueOf(mapGroup.getGroupType()); + mapIds = JsonUtils.readCollection(mapGroup.getMapIds(),List.class,Long.class); + } + + public MapGroup convert2DB() { + MapGroup mapGroup = new MapGroup(); + mapGroup.setId(id); + mapGroup.setGroupName(name); + mapGroup.setGroupType(type.name()); + mapGroup.setMapIds(JsonUtils.writeValueAsString(mapIds)); + return mapGroup; + } + + public static List convert2VOList(List list) { + List voList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(list)) { + list.forEach(mapGroup -> voList.add(new MapGroupVO(mapGroup))); + } + return voList; + } +} diff --git a/src/main/resources/mybatis/mapper/MapGroupDAO.xml b/src/main/resources/mybatis/mapper/MapGroupDAO.xml new file mode 100644 index 000000000..158e753f6 --- /dev/null +++ b/src/main/resources/mybatis/mapper/MapGroupDAO.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + 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, group_name, group_type, map_ids + + + + + delete from map_group + where id = #{id,jdbcType=BIGINT} + + + delete from map_group + + + + + + insert into map_group (group_name, group_type, map_ids + ) + values (#{groupName,jdbcType=VARCHAR}, #{groupType,jdbcType=VARCHAR}, #{mapIds,jdbcType=VARCHAR} + ) + + + insert into map_group + + + group_name, + + + group_type, + + + map_ids, + + + + + #{groupName,jdbcType=VARCHAR}, + + + #{groupType,jdbcType=VARCHAR}, + + + #{mapIds,jdbcType=VARCHAR}, + + + + + + update map_group + + + id = #{record.id,jdbcType=BIGINT}, + + + group_name = #{record.groupName,jdbcType=VARCHAR}, + + + group_type = #{record.groupType,jdbcType=VARCHAR}, + + + map_ids = #{record.mapIds,jdbcType=VARCHAR}, + + + + + + + + update map_group + set id = #{record.id,jdbcType=BIGINT}, + group_name = #{record.groupName,jdbcType=VARCHAR}, + group_type = #{record.groupType,jdbcType=VARCHAR}, + map_ids = #{record.mapIds,jdbcType=VARCHAR} + + + + + + update map_group + + + group_name = #{groupName,jdbcType=VARCHAR}, + + + group_type = #{groupType,jdbcType=VARCHAR}, + + + map_ids = #{mapIds,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update map_group + set group_name = #{groupName,jdbcType=VARCHAR}, + group_type = #{groupType,jdbcType=VARCHAR}, + map_ids = #{mapIds,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file