Commit 1244cf377ac08cc8943a2ffaa26836bd6980ba01

Authored by yiming
1 parent 72bbdd01

站点同步定时器

bsthLineProfiles/src/main/java/com/ruoyi/project/monitor/job/task/RyTask.java
... ... @@ -6,9 +6,14 @@ import java.util.Date;
6 6 import java.util.HashMap;
7 7 import java.util.List;
8 8 import java.util.Map;
  9 +import java.util.stream.Collectors;
9 10  
  11 +import cn.hutool.http.HttpUtil;
  12 +import com.alibaba.fastjson.JSONObject;
10 13 import com.ruoyi.common.utils.security.ShiroUtils;
11 14 import com.ruoyi.project.system.dept.service.DeptServiceImpl;
  15 +import com.ruoyi.project.system.line.domain.BsthStation;
  16 +import com.ruoyi.project.system.line.mapper.BsthStationMapper;
12 17 import com.ruoyi.project.system.user.domain.User;
13 18 import org.apache.shiro.util.ThreadContext;
14 19 import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
... ... @@ -36,6 +41,9 @@ public class RyTask {
36 41 @Autowired
37 42 DeptServiceImpl deptService;
38 43  
  44 + @Autowired
  45 + BsthStationMapper bsthStationMapper;
  46 +
39 47 public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
40 48 System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
41 49 }
... ... @@ -129,4 +137,25 @@ public class RyTask {
129 137 ThreadContext.bind(manager);
130 138 deptService.updateSysDept();
131 139 }
  140 +
  141 + public void updateStation(){
  142 + List<BsthStation> bsthStations=bsthStationMapper.selectBsthStation();
  143 + Map<String,List<BsthStation>> m=bsthStations.stream().collect(Collectors.groupingBy(v->v.getStationCode()));
  144 + String url="https://180.167.126.126:18991/prod-api/service/interfact/getStation";
  145 + JSONArray jsonArray= JSONObject.parseObject(HttpUtil.get(url)).getJSONArray("data");
  146 + for (Object o : jsonArray) {
  147 + BsthStation b=JSONObject.parseObject(o.toString(), BsthStation.class);
  148 + List<BsthStation> bsthStationList=m.get(b.getStationCode());
  149 + if(bsthStationList==null){
  150 + bsthStationMapper.insertBsthStation(b);
  151 + }else {
  152 + BsthStation bsthStation=bsthStationList.get(0);
  153 + if(!b.equals(bsthStation)){
  154 + bsthStationMapper.updateBsthStation(b);
  155 + }
  156 + }
  157 +
  158 + }
  159 + }
  160 +
132 161 }
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/domain/BsthStation.java
... ... @@ -3,6 +3,8 @@ package com.ruoyi.project.system.line.domain;
3 3 import org.apache.commons.lang3.builder.ToStringBuilder;
4 4 import org.apache.commons.lang3.builder.ToStringStyle;
5 5  
  6 +import java.util.Objects;
  7 +
6 8 /**
7 9 * 站点信息 过程或现状的站级信息都引用此站点信息对象 bsth_t_station
8 10 *
... ... @@ -63,53 +65,49 @@ public class BsthStation
63 65 private String hasMetro;
64 66  
65 67 private String remark;
  68 + /** 街道 */
  69 + private String streetTown;
66 70  
67   - public void setId(Long id)
68   - {
69   - this.id = id;
70   - }
71   -
72   - public Long getId()
73   - {
  71 + public Long getId() {
74 72 return id;
75 73 }
76   - public void setStandardStationCode(String standardStationCode)
77   - {
78   - this.standardStationCode = standardStationCode;
  74 +
  75 + public void setId(Long id) {
  76 + this.id = id;
79 77 }
80 78  
81   - public String getStandardStationCode()
82   - {
  79 + public String getStandardStationCode() {
83 80 return standardStationCode;
84 81 }
85   - public void setStationCode(String stationCode)
86   - {
87   - this.stationCode = stationCode;
  82 +
  83 + public void setStandardStationCode(String standardStationCode) {
  84 + this.standardStationCode = standardStationCode;
88 85 }
89 86  
90   - public String getStationCode()
91   - {
  87 + public String getStationCode() {
92 88 return stationCode;
93 89 }
94   - public void setStationName(String stationName)
95   - {
96   - this.stationName = stationName;
  90 +
  91 + public void setStationCode(String stationCode) {
  92 + this.stationCode = stationCode;
97 93 }
98 94  
99   - public String getStationName()
100   - {
  95 + public String getStationName() {
101 96 return stationName;
102 97 }
103   - public void setStationAddress(String stationAddress)
104   - {
105   - this.stationAddress = stationAddress;
  98 +
  99 + public void setStationName(String stationName) {
  100 + this.stationName = stationName;
106 101 }
107 102  
108   - public String getStationAddress()
109   - {
  103 + public String getStationAddress() {
110 104 return stationAddress;
111 105 }
112 106  
  107 + public void setStationAddress(String stationAddress) {
  108 + this.stationAddress = stationAddress;
  109 + }
  110 +
113 111 public String getBoardType() {
114 112 return boardType;
115 113 }
... ... @@ -118,126 +116,145 @@ public class BsthStation
118 116 this.boardType = boardType;
119 117 }
120 118  
121   - public void setStationType(String stationType)
122   - {
  119 + public String getStationType() {
  120 + return stationType;
  121 + }
  122 +
  123 + public void setStationType(String stationType) {
123 124 this.stationType = stationType;
124 125 }
125 126  
126   - public String getStationType()
127   - {
128   - return stationType;
  127 + public String getAnnular() {
  128 + return annular;
129 129 }
130   - public void setAnnular(String annular)
131   - {
  130 +
  131 + public void setAnnular(String annular) {
132 132 this.annular = annular;
133 133 }
134 134  
135   - public String getAnnular()
136   - {
137   - return annular;
  135 + public String getArea() {
  136 + return area;
138 137 }
139   - public void setArea(String area)
140   - {
  138 +
  139 + public void setArea(String area) {
141 140 this.area = area;
142 141 }
143 142  
144   - public String getArea()
145   - {
146   - return area;
  143 + public String getRoadName() {
  144 + return roadName;
147 145 }
148   - public void setRoadName(String roadName)
149   - {
  146 +
  147 + public void setRoadName(String roadName) {
150 148 this.roadName = roadName;
151 149 }
152 150  
153   - public String getRoadName()
154   - {
155   - return roadName;
  151 + public Double getLonBd() {
  152 + return lonBd;
156 153 }
157   - public void setLonBd(Double lonBd)
158   - {
  154 +
  155 + public void setLonBd(Double lonBd) {
159 156 this.lonBd = lonBd;
160 157 }
161 158  
162   - public Double getLonBd()
163   - {
164   - return lonBd;
  159 + public Double getLatBd() {
  160 + return latBd;
165 161 }
166   - public void setLatBd(Double latBd)
167   - {
  162 +
  163 + public void setLatBd(Double latBd) {
168 164 this.latBd = latBd;
169 165 }
170 166  
171   - public Double getLatBd()
172   - {
173   - return latBd;
  167 + public Double getLonGps() {
  168 + return lonGps;
174 169 }
175   - public void setLonGps(Double lonGps)
176   - {
  170 +
  171 + public void setLonGps(Double lonGps) {
177 172 this.lonGps = lonGps;
178 173 }
179 174  
180   - public Double getLonGps()
181   - {
182   - return lonGps;
  175 + public Double getLatGps() {
  176 + return latGps;
183 177 }
184   - public void setLatGps(Double latGps)
185   - {
  178 +
  179 + public void setLatGps(Double latGps) {
186 180 this.latGps = latGps;
187 181 }
188 182  
189   - public Double getLatGps()
190   - {
191   - return latGps;
  183 + public String getDistrict() {
  184 + return district;
192 185 }
193   - public void setDistrict(String district)
194   - {
  186 +
  187 + public void setDistrict(String district) {
195 188 this.district = district;
196 189 }
197 190  
198   - public String getDistrict()
199   - {
200   - return district;
  191 + public String getLineList() {
  192 + return lineList;
201 193 }
202   - public void setLineList(String lineList)
203   - {
  194 +
  195 + public void setLineList(String lineList) {
204 196 this.lineList = lineList;
205 197 }
206 198  
207   - public String getLineList()
208   - {
209   - return lineList;
  199 + public String getHasMetro() {
  200 + return hasMetro;
210 201 }
211   - public void setHasMetro(String hasMetro)
212   - {
  202 +
  203 + public void setHasMetro(String hasMetro) {
213 204 this.hasMetro = hasMetro;
214 205 }
215 206  
216   - public String getHasMetro()
217   - {
218   - return hasMetro;
  207 + public String getRemark() {
  208 + return remark;
  209 + }
  210 +
  211 + public void setRemark(String remark) {
  212 + this.remark = remark;
  213 + }
  214 +
  215 + public String getStreetTown() {
  216 + return streetTown;
219 217 }
220 218  
  219 + public void setStreetTown(String streetTown) {
  220 + this.streetTown = streetTown;
  221 + }
221 222  
222 223 @Override
223 224 public String toString() {
224   - return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
225   - .append("id", getId())
226   - .append("standardStationCode", getStandardStationCode())
227   - .append("stationCode", getStationCode())
228   - .append("stationName", getStationName())
229   - .append("stationAddress", getStationAddress())
230   - .append("stationType", getStationType())
231   - .append("annular", getAnnular())
232   - .append("area", getArea())
233   - .append("roadName", getRoadName())
234   - .append("lonBd", getLonBd())
235   - .append("latBd", getLatBd())
236   - .append("lonGps", getLonGps())
237   - .append("latGps", getLatGps())
238   - .append("district", getDistrict())
239   - .append("lineList", getLineList())
240   - .append("hasMetro", getHasMetro())
241   - .toString();
  225 + return "BsthStation{" +
  226 + "id=" + id +
  227 + ", standardStationCode='" + standardStationCode + '\'' +
  228 + ", stationCode='" + stationCode + '\'' +
  229 + ", stationName='" + stationName + '\'' +
  230 + ", stationAddress='" + stationAddress + '\'' +
  231 + ", boardType='" + boardType + '\'' +
  232 + ", stationType='" + stationType + '\'' +
  233 + ", annular='" + annular + '\'' +
  234 + ", area='" + area + '\'' +
  235 + ", roadName='" + roadName + '\'' +
  236 + ", lonBd=" + lonBd +
  237 + ", latBd=" + latBd +
  238 + ", lonGps=" + lonGps +
  239 + ", latGps=" + latGps +
  240 + ", district='" + district + '\'' +
  241 + ", lineList='" + lineList + '\'' +
  242 + ", hasMetro='" + hasMetro + '\'' +
  243 + ", remark='" + remark + '\'' +
  244 + ", streetTown='" + streetTown + '\'' +
  245 + '}';
  246 + }
  247 +
  248 + @Override
  249 + public boolean equals(Object o) {
  250 + if (this == o) return true;
  251 + if (o == null || getClass() != o.getClass()) return false;
  252 + BsthStation that = (BsthStation) o;
  253 + return Objects.equals(standardStationCode, that.standardStationCode) && Objects.equals(stationCode, that.stationCode) && Objects.equals(stationName, that.stationName) && Objects.equals(stationAddress, that.stationAddress) && Objects.equals(boardType, that.boardType) && Objects.equals(stationType, that.stationType) && Objects.equals(annular, that.annular) && Objects.equals(area, that.area) && Objects.equals(roadName, that.roadName) && Objects.equals(lonBd, that.lonBd) && Objects.equals(latBd, that.latBd) && Objects.equals(lonGps, that.lonGps) && Objects.equals(latGps, that.latGps) && Objects.equals(district, that.district) && Objects.equals(lineList, that.lineList) && Objects.equals(hasMetro, that.hasMetro) && Objects.equals(remark, that.remark) && Objects.equals(streetTown, that.streetTown);
  254 + }
  255 +
  256 + @Override
  257 + public int hashCode() {
  258 + return Objects.hash(standardStationCode, stationCode, stationName, stationAddress, boardType, stationType, annular, area, roadName, lonBd, latBd, lonGps, latGps, district, lineList, hasMetro, remark, streetTown);
242 259 }
243 260 }
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/mapper/BsthStationMapper.java
... ... @@ -10,4 +10,11 @@ import java.util.List;
10 10 public interface BsthStationMapper
11 11 {
12 12 List<BsthStation> selectBsthStationListByLoc(@Param("lng")String lng, @Param("lat")String lat, @Param("dis")String dis);
  13 +
  14 + List<BsthStation> selectBsthStation();
  15 +
  16 + void updateBsthStation(BsthStation bsthStation);
  17 +
  18 + void insertBsthStation(BsthStation bsthStation);
  19 +
13 20 }
... ...
bsthLineProfiles/src/main/resources/mybatis/mybatis/system/BsthStationMapper.xml
... ... @@ -37,5 +37,76 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
37 37 ) &lt; ${dis}
38 38 </select>
39 39  
  40 + <select id="selectBsthStation" resultMap="BsthStationResult">
  41 + select id, standard_station_code, station_code, station_name, station_address, station_type, board_type, annular, area, road_name, lon_bd, lat_bd, lon_gps, lat_gps, district, line_list, has_metro, remark from bsth_t_station
  42 + </select>
  43 +
  44 + <update id="updateBsthStation" parameterType="com.ruoyi.project.system.line.domain.BsthStation">
  45 + update bsth_t_station
  46 + <trim prefix="SET" suffixOverrides=",">
  47 + <if test="standardStationCode != null">standard_station_code = #{standardStationCode},</if>
  48 + <if test="stationName != null">station_name = #{stationName},</if>
  49 + <if test="stationAddress != null">station_address = #{stationAddress},</if>
  50 + <if test="stationType != null">station_type = #{stationType},</if>
  51 + <if test="boardType != null">board_type = #{boardType},</if>
  52 + <if test="annular != null">annular = #{annular},</if>
  53 + <if test="area != null">area = #{area},</if>
  54 + <if test="roadName != null">road_name = #{roadName},</if>
  55 + <if test="lonBd != null">lon_bd = #{lonBd},</if>
  56 + <if test="latBd != null">lat_bd = #{latBd},</if>
  57 + <if test="lonGps != null">lon_gps = #{lonGps},</if>
  58 + <if test="latGps != null">lat_gps = #{latGps},</if>
  59 + <if test="district != null">district = #{district},</if>
  60 + <if test="lineList != null">line_list = #{lineList},</if>
  61 + <if test="hasMetro != null">has_metro = #{hasMetro},</if>
  62 + <if test="remark != null">remark = #{remark},</if>
  63 + <if test="streetTown != null">street_town = #{streetTown},</if>
  64 + </trim>
  65 + where station_code = #{stationCode}
  66 + </update>
  67 +
  68 + <insert id="insertBsthStation" parameterType="com.ruoyi.project.system.line.domain.BsthStation">
  69 + insert into bsth_t_station
  70 + <trim prefix="(" suffix=")" suffixOverrides=",">
  71 + <if test="standardStationCode != null and standardStationCode != ''">standard_station_code,</if>
  72 + <if test="stationCode != null and stationCode != ''">station_code,</if>
  73 + <if test="stationName != null and stationName != ''">station_name,</if>
  74 + <if test="stationAddress != null and stationAddress != ''">station_address,</if>
  75 + <if test="stationType != null and stationType != ''">station_type,</if>
  76 + <if test="boardType != null and boardType != ''">board_type,</if>
  77 + <if test="annular != null and annular != ''">annular,</if>
  78 + <if test="area != null and area != ''">area,</if>
  79 + <if test="roadName != null and roadName != ''">road_name,</if>
  80 + <if test="lonBd != null and lonBd != ''">lon_bd,</if>
  81 + <if test="latBd != null and latBd != ''">lat_bd,</if>
  82 + <if test="lonGps != null and lonGps != ''">lon_gps,</if>
  83 + <if test="latGps != null and latGps != ''">lat_gps,</if>
  84 + <if test="district != null and district != ''">district,</if>
  85 + <if test="lineList != null and lineList != ''">line_list,</if>
  86 + <if test="hasMetro != null and hasMetro != ''">has_metro,</if>
  87 + <if test="remark != null and remark != ''">remark,</if>
  88 + <if test="streetTown != null and streetTown != ''">street_town,</if>
  89 + </trim>
  90 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  91 + <if test="standardStationCode != null and standardStationCode != ''">#{standardStationCode},</if>
  92 + <if test="stationCode != null and stationCode != ''">#{stationCode},</if>
  93 + <if test="stationName != null and stationName != ''">#{stationName},</if>
  94 + <if test="stationAddress != null and stationAddress != ''">#{stationAddress},</if>
  95 + <if test="stationType != null and stationType != ''">#{stationType},</if>
  96 + <if test="boardType != null and boardType != ''">#{boardType},</if>
  97 + <if test="annular != null and annular != ''">#{annular},</if>
  98 + <if test="area != null and area != ''">#{area},</if>
  99 + <if test="roadName != null and roadName != ''">#{roadName},</if>
  100 + <if test="lonBd != null and lonBd != ''">#{lonBd},</if>
  101 + <if test="latBd != null and latBd != ''">#{latBd},</if>
  102 + <if test="lonGps != null and lonGps != ''">#{lonGps},</if>
  103 + <if test="latGps != null and latGps != ''">#{latGps},</if>
  104 + <if test="district != null and district != ''">#{district},</if>
  105 + <if test="lineList != null and lineList != ''">#{lineList},</if>
  106 + <if test="hasMetro != null and hasMetro != ''">#{hasMetro},</if>
  107 + <if test="remark != null and remark != ''">#{remark},</if>
  108 + <if test="streetTown != null and streetTown != ''">#{streetTown},</if>
  109 + </trim>
  110 + </insert>
40 111  
41 112 </mapper>
42 113 \ No newline at end of file
... ...
bsthLineProfiles/src/main/resources/templates/system/line/map.html
... ... @@ -68,7 +68,7 @@ body, html, #container {
68 68 <ul class="nav nav-tabs" role="tablist">
69 69 <li role="presentation" class="active"><a onclick="show('station','road','line','area')" role="tab" data-toggle="tab">地点查询</a></li>
70 70 <li role="presentation"><a onclick="show('road','station','line','area')" role="tab" data-toggle="tab">道路查询</a></li>
71   - <li role="presentation"><a onclick="show('line','road','station','area')" role="tab" data-toggle="tab">途线路</a></li>
  71 + <li role="presentation"><a onclick="show('line','road','station','area')" role="tab" data-toggle="tab">途线路</a></li>
72 72 <li role="presentation"><a onclick="show('area','road','station','line')" role="tab" data-toggle="tab">区域查询</a></li>
73 73 </ul>
74 74  
... ... @@ -249,7 +249,7 @@ body, html, #container {
249 249 function a(lng,lat,distance){
250 250 $.get("../line/getStation?lng="
251 251 +lng + "&lat=" + lat + "&dis="
252   - + distance / 1000, function(data) {
  252 + + distance*2/ 1000, function(data) {
253 253 if (data.code == "0") {
254 254 var bus=new Array();
255 255 for ( var i in data.data) {
... ... @@ -299,7 +299,7 @@ body, html, #container {
299 299 document.getElementById('bus').innerHTML=str;
300 300 document.getElementById('count').innerHTML='共'+data.data.length+'个站点 &nbsp;&nbsp;&nbsp; 共'+bus.length+'条线路';
301 301 // 绘制圆
302   - var circle = new BMapGL.Circle(new BMapGL.Point(lng,lat), distance/2, {
  302 + var circle = new BMapGL.Circle(new BMapGL.Point(lng,lat), distance, {
303 303 strokeColor: 'blue',
304 304 strokeWeight: 2,
305 305 strokeOpacity: 0.5
... ... @@ -313,7 +313,7 @@ body, html, #container {
313 313 function b(lng,lat,distance,roadName){
314 314 $.get("../line/getStation?lng="
315 315 +lng + "&lat=" + lat + "&dis="
316   - + distance / 1000, function(data) {
  316 + + distance*2/ 1000, function(data) {
317 317 if (data.code == "0") {
318 318 var bus=new Array();
319 319 var c=0;
... ...