This commit is contained in:
Yutousama 2020-01-17 18:02:29 +08:00
parent 83613ae630
commit a496f9c780
5 changed files with 205 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -1,15 +1,25 @@
package com.yutou.maptop.Bean; package com.yutou.maptop.Bean;
import com.yutou.jianrdb.Bean.MapNode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
public class MapTop { public class MapTop {
private int id; private int id;
private int mapId; private int mapId;
private int mapNode; private int mapNode;
private String shipTeam; private String shipTeam;
private MapNode node;
public MapNode getNode() {
return node;
}
public void setNode(MapNode node) {
this.node = node;
}
public int getId() { public int getId() {
return id; return id;
@ -32,7 +42,9 @@ public class MapTop {
public String getShipTeam() { public String getShipTeam() {
return shipTeam; return shipTeam;
} }
public void setShipTeamTo(String shipTeam){
this.shipTeam=shipTeam;
}
public void setShipTeam(String shipTeam) { public void setShipTeam(String shipTeam) {
List<Integer> list=new ArrayList<>(); List<Integer> list=new ArrayList<>();
shipTeam=shipTeam.replace("[",""); shipTeam=shipTeam.replace("[","");

View File

@ -1,8 +1,10 @@
package com.yutou.maptop.services; package com.yutou.maptop.services;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yutou.jianrdb.Dao.MapNodeDao;
import com.yutou.maptop.Bean.MapTop; import com.yutou.maptop.Bean.MapTop;
import com.yutou.maptop.Dao.MapDao; import com.yutou.maptop.Dao.MapDao;
import com.yutou.mybatis.dao.ZsShipTypeMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -12,13 +14,51 @@ import java.util.List;
public class MapTopService { public class MapTopService {
@Resource @Resource
MapDao mapDao; MapDao mapDao;
@Resource
MapNodeDao nodeDao;
@Resource
ZsShipTypeMapper shipTypeMapper;
public List<MapTop> selectMapByMapId(int mapId, int limit, int count) { public List<MapTop> selectMapByMapId(int mapId, int limit, int count) {
return mapDao.selectMapByMapId(mapId, limit, count); List<MapTop> list=mapDao.selectMapByMapId(mapId, limit, count);
return getMapTops(list);
} }
public List<MapTop> selectMap(int limit,int count){ public List<MapTop> selectMap(int limit,int count){
return mapDao.selectMap(limit, count); List<MapTop> list=mapDao.selectMap(limit, count);
return getMapTops(list);
}
private List<MapTop> getMapTops(List<MapTop> 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) { public int insertMapTop(MapTop top) {