From a496f9c78095bddeef118ed5dde67ccb81799bfe Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Fri, 17 Jan 2020 18:02:29 +0800 Subject: [PATCH] update --- .../java/com/yutou/jianrdb/Bean/MapNode.java | 121 ++++++++++++++++++ .../com/yutou/jianrdb/Dao/MapNodeDao.java | 12 ++ .../yutou/jianrdb/Mapper/MapNodeService.java | 16 +++ .../java/com/yutou/maptop/Bean/MapTop.java | 16 ++- .../yutou/maptop/services/MapTopService.java | 44 ++++++- 5 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/yutou/jianrdb/Bean/MapNode.java create mode 100644 src/main/java/com/yutou/jianrdb/Dao/MapNodeDao.java create mode 100644 src/main/java/com/yutou/jianrdb/Mapper/MapNodeService.java diff --git a/src/main/java/com/yutou/jianrdb/Bean/MapNode.java b/src/main/java/com/yutou/jianrdb/Bean/MapNode.java new file mode 100644 index 0000000..5423f1c --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Bean/MapNode.java @@ -0,0 +1,121 @@ +package com.yutou.jianrdb.Bean; + +public class MapNode { + private int id; + private String flag; + private int chapter; + private int level; + private int level_pve_id; + private int level_type; + private int type; + private String type_desc; + private String node_name; + private String level_name; + private String chapter_name; + private String chapter_sub_name; + private String chapter_tag; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + public int getChapter() { + return chapter; + } + + public void setChapter(int chapter) { + this.chapter = chapter; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public int getLevel_pve_id() { + return level_pve_id; + } + + public void setLevel_pve_id(int level_pve_id) { + this.level_pve_id = level_pve_id; + } + + public int getLevel_type() { + return level_type; + } + + public void setLevel_type(int level_type) { + this.level_type = level_type; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getType_desc() { + return type_desc; + } + + public void setType_desc(String type_desc) { + this.type_desc = type_desc; + } + + public String getNode_name() { + return node_name; + } + + public void setNode_name(String node_name) { + this.node_name = node_name; + } + + public String getLevel_name() { + return level_name; + } + + public void setLevel_name(String level_name) { + this.level_name = level_name; + } + + public String getChapter_name() { + return chapter_name; + } + + public void setChapter_name(String chapter_name) { + this.chapter_name = chapter_name; + } + + public String getChapter_sub_name() { + return chapter_sub_name; + } + + public void setChapter_sub_name(String chapter_sub_name) { + this.chapter_sub_name = chapter_sub_name; + } + + public String getChapter_tag() { + return chapter_tag; + } + + public void setChapter_tag(String chapter_tag) { + this.chapter_tag = chapter_tag; + } +} diff --git a/src/main/java/com/yutou/jianrdb/Dao/MapNodeDao.java b/src/main/java/com/yutou/jianrdb/Dao/MapNodeDao.java new file mode 100644 index 0000000..f7538f6 --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Dao/MapNodeDao.java @@ -0,0 +1,12 @@ +package com.yutou.jianrdb.Dao; + +import com.yutou.jianrdb.Bean.MapNode; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.beans.factory.annotation.Qualifier; + +@Qualifier("db2SqlSessionTemplate") +public interface MapNodeDao { + @Select("select * from zs_node_info where id=#{node}") + MapNode selectNodeByNode(@Param("node")int node); +} diff --git a/src/main/java/com/yutou/jianrdb/Mapper/MapNodeService.java b/src/main/java/com/yutou/jianrdb/Mapper/MapNodeService.java new file mode 100644 index 0000000..b2a648b --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Mapper/MapNodeService.java @@ -0,0 +1,16 @@ +package com.yutou.jianrdb.Mapper; + +import com.yutou.jianrdb.Bean.MapNode; +import com.yutou.jianrdb.Dao.MapNodeDao; + +import javax.annotation.Resource; + +public class MapNodeService implements MapNodeDao { + @Resource + MapNodeDao dao; + + @Override + public MapNode selectNodeByNode(int node) { + return dao.selectNodeByNode(node); + } +} diff --git a/src/main/java/com/yutou/maptop/Bean/MapTop.java b/src/main/java/com/yutou/maptop/Bean/MapTop.java index e389e67..bd8773d 100644 --- a/src/main/java/com/yutou/maptop/Bean/MapTop.java +++ b/src/main/java/com/yutou/maptop/Bean/MapTop.java @@ -1,15 +1,25 @@ package com.yutou.maptop.Bean; +import com.yutou.jianrdb.Bean.MapNode; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Optional; public class MapTop { private int id; private int mapId; private int mapNode; private String shipTeam; + private MapNode node; + + public MapNode getNode() { + return node; + } + + public void setNode(MapNode node) { + this.node = node; + } public int getId() { return id; @@ -32,7 +42,9 @@ public class MapTop { public String getShipTeam() { return shipTeam; } - + public void setShipTeamTo(String shipTeam){ + this.shipTeam=shipTeam; + } public void setShipTeam(String shipTeam) { List list=new ArrayList<>(); shipTeam=shipTeam.replace("[",""); diff --git a/src/main/java/com/yutou/maptop/services/MapTopService.java b/src/main/java/com/yutou/maptop/services/MapTopService.java index 5327f1a..1325c7c 100644 --- a/src/main/java/com/yutou/maptop/services/MapTopService.java +++ b/src/main/java/com/yutou/maptop/services/MapTopService.java @@ -1,8 +1,10 @@ package com.yutou.maptop.services; import com.alibaba.fastjson.JSONArray; +import com.yutou.jianrdb.Dao.MapNodeDao; import com.yutou.maptop.Bean.MapTop; import com.yutou.maptop.Dao.MapDao; +import com.yutou.mybatis.dao.ZsShipTypeMapper; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -12,13 +14,51 @@ import java.util.List; public class MapTopService { @Resource MapDao mapDao; + @Resource + MapNodeDao nodeDao; + @Resource + ZsShipTypeMapper shipTypeMapper; public List selectMapByMapId(int mapId, int limit, int count) { - return mapDao.selectMapByMapId(mapId, limit, count); + List list=mapDao.selectMapByMapId(mapId, limit, count); + return getMapTops(list); } public List selectMap(int limit,int count){ - return mapDao.selectMap(limit, count); + List list=mapDao.selectMap(limit, count); + return getMapTops(list); + } + + private List getMapTops(List list) { + for (MapTop mapTop : list) { + mapTop.setNode(nodeDao.selectNodeByNode(mapTop.getMapNode())); + String tmp=mapTop.getShipTeam().replace("[",""); + tmp=tmp.replace("]",""); + String[] shipType=tmp.split(","); + int tid=-1; + int old=-1; + int index=0; + String stype=""; + int mapId=mapTop.getId(); + for (String type : shipType) { + index++; + if(tid!=Integer.parseInt(type)){ + tid=Integer.parseInt(type); + if(old==-1){ + old=tid; + } + stype+=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+","; + old=tid; + index=0; + } + } + if(stype.equals("")){ + stype=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+","; + } + stype = stype.substring(0, stype.length() - 1); + mapTop.setShipTeamTo(stype); + } + return list; } public int insertMapTop(MapTop top) {