From 2841e102ea4b5e9ddd40327829431a25a9122cd9 Mon Sep 17 00:00:00 2001 From: wanglizhong <wlz> Date: 星期日, 04 五月 2025 17:20:28 +0800 Subject: [PATCH] fix:增加cms同步 --- ruoyi-ui/src/views/system/vehicle/index.vue | 32 + ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleLocationResponse.java | 96 ++++ ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CmsVehicleSyncTask.java | 174 ++++++++ ruoyi-system/src/main/java/com/ruoyi/system/service/ICmsGpsCollectService.java | 47 ++ ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java | 70 +++ ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GpsSyncTask.java | 40 + .cursor/rules/ruoyi-rule.mdc | 13 ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsGpsLoginResponse.java | 56 ++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java | 199 +++++++++ ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceResponse.java | 223 +++++++++++ ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleInfo.java | 13 sql/cms_vehicle_sync_job.sql | 30 + ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml | 36 + ruoyi-ui/src/views/system/gps/map.vue | 40 + ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceListResponse.java | 74 +++ 15 files changed, 1,099 insertions(+), 44 deletions(-) diff --git a/.cursor/rules/ruoyi-rule.mdc b/.cursor/rules/ruoyi-rule.mdc new file mode 100644 index 0000000..1666a5b --- /dev/null +++ b/.cursor/rules/ruoyi-rule.mdc @@ -0,0 +1,13 @@ +--- +description: +globs: +alwaysApply: false +--- +杩欐槸涓�涓猺uoyi椤圭洰锛屽墠绔唬鐮佹斁鍏ュ埌ruoyi-ui鐩綍涓嬶紝鍓嶇椤圭洰閲囩敤vue杩涜浠g爜寮�鍙戯紱 +鍚庣椤圭洰涓湁ruoyi-system,ruoyi-admin,ruoyi-common,ruoyi-framework,ruoyi-quartz +ruoyi-system鏄搷浣滄暟鎹簱鐨勭浉鍏充唬鐮侊紱 +ruoyi-admin鏄潰鍚憉i鐨凙PI鎺ュ彛锛屽鍚勭controller; +ruoyi-common鏄竴涓�氱敤鎬х殑浠g爜宸ュ叿绫�; +ruoyi-framework鏄鏋舵�ч」鐩紱 + +ruoyi-quartz鏄鍒掍换鍔¢」鐩�; \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java index 9afdb90..d639140 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java @@ -116,4 +116,74 @@ return response.toString(); } + + /** + * 鍙戦�丟ET璇锋眰 + * @param url 璇锋眰URL + * @param params 璇锋眰鍙傛暟 + * @return 鍝嶅簲鍐呭 + */ + public static String get(String url, Map<String, String> params) { + StringBuilder response = new StringBuilder(); + HttpURLConnection conn = null; + try { + // 鏋勫缓甯﹀弬鏁扮殑URL + StringBuilder urlBuilder = new StringBuilder(url); + if (params != null && !params.isEmpty()) { + urlBuilder.append("?"); + for (Map.Entry<String, String> entry : params.entrySet()) { + urlBuilder.append(entry.getKey()) + .append("=") + .append(entry.getValue()) + .append("&"); + } + urlBuilder.deleteCharAt(urlBuilder.length() - 1); // 鍒犻櫎鏈�鍚庝竴涓�& + } + + // 鍒涘缓杩炴帴 + URL requestUrl = new URL(urlBuilder.toString()); + boolean isHttps = url.toLowerCase().startsWith("https"); + + // 鏍规嵁鍗忚绫诲瀷鍒涘缓杩炴帴 + if (isHttps) { + conn = (HttpsURLConnection) requestUrl.openConnection(); + } else { + conn = (HttpURLConnection) requestUrl.openConnection(); + } + + // 璁剧疆璇锋眰灞炴�� + conn.setRequestMethod("GET"); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestProperty("Accept", "application/json"); + + // 璁剧疆瓒呮椂鏃堕棿 + conn.setConnectTimeout(CONNECT_TIMEOUT); + conn.setReadTimeout(READ_TIMEOUT); + + // 鑾峰彇鍝嶅簲鐮� + int responseCode = conn.getResponseCode(); + if (responseCode != HttpURLConnection.HTTP_OK) { + throw new RuntimeException("HTTP璇锋眰澶辫触锛屽搷搴旂爜: " + responseCode); + } + + // 璇诲彇鍝嶅簲 + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + } + + } catch (Exception e) { + throw new RuntimeException("HTTP璇锋眰澶辫触: " + e.getMessage(), e); + } finally { + if (conn != null) { + conn.disconnect(); + } + } + + return response.toString(); + } } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CmsVehicleSyncTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CmsVehicleSyncTask.java new file mode 100644 index 0000000..e414f6a --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/CmsVehicleSyncTask.java @@ -0,0 +1,174 @@ +package com.ruoyi.quartz.task; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.CmsVehicleDeviceResponse; +import com.ruoyi.system.domain.CmsVehicleLocationResponse; +import com.ruoyi.system.domain.VehicleGps; +import com.ruoyi.system.domain.VehicleInfo; +import com.ruoyi.system.service.ICmsGpsCollectService; +import com.ruoyi.system.service.IVehicleGpsService; +import com.ruoyi.system.service.IVehicleInfoService; + +/** + * CMS杞﹁締鍚屾瀹氭椂浠诲姟 + * + * @author ruoyi + */ +@Component("cmsVehicleSyncTask") +public class CmsVehicleSyncTask { + private static final Logger log = LoggerFactory.getLogger(CmsVehicleSyncTask.class); + + @Autowired + private ICmsGpsCollectService cmsGpsCollectService; + + @Autowired + private IVehicleInfoService vehicleInfoService; + + @Autowired + private IVehicleGpsService vehicleGpsService; + + public void syncVehicleInfo() { + log.info("寮�濮嬪悓姝MS杞﹁締淇℃伅"); + try { + // 鑾峰彇CMS鎵�鏈夎溅杈嗕俊鎭� + CmsVehicleDeviceResponse response = cmsGpsCollectService.queryVehicleDevices(); + if (response.getResult() != 0) { + log.error("鑾峰彇CMS杞﹁締淇℃伅澶辫触"); + return; + } + + // 鑾峰彇鎵�鏈塁MS杞﹁締鐨勮溅鐗屽彿 + List<String> cmsPlateNos = new ArrayList<>(); + response.getVehicles().forEach(vehicle -> { + if (StringUtils.isNotEmpty(vehicle.getNm())) { + // 浠庤溅杈嗗悕绉颁腑鎻愬彇杞︾墝鍙凤紙鍋囪鏍煎紡涓�"鈽呰溅鐗屽彿锛堝湴鍖猴級"锛� + String plateNo =this.getPlateNo(vehicle.getNm()); + cmsPlateNos.add(plateNo); + } + }); + + // 鑾峰彇鏈湴鎵�鏈夎溅杈� + VehicleInfo query = new VehicleInfo(); + query.setStatus("0"); + List<VehicleInfo> localVehicles = vehicleInfoService.selectVehicleInfoList(query); + + //鎵惧埌鎵�鏈夎溅杈嗕腑涓嶆槸CMS骞冲彴鐨勮溅杈� + List<String> notCmsVehicles = localVehicles.stream().filter(e->!e.getPlatformCode().equals("CMS")).map(e->e.getVehicleNo()).collect((Collectors.toList())); + + + List<String> onlyCms=cmsPlateNos.stream().filter(e->!notCmsVehicles.contains(e)).collect((Collectors.toList())); + + Integer syncCarCount=0; + for(String e:onlyCms){ + VehicleInfo vehicleInfo = new VehicleInfo(); + vehicleInfo.setVehicleNo(e); + vehicleInfo.setPlatformCode("CMS"); + vehicleInfo.setStatus("0"); + //濡傛灉杞﹁締涓嶅瓨鍦紝鍒欐彃鍏� + if (vehicleInfoService.selectVehicleInfoList(vehicleInfo).size()==0) { + vehicleInfoService.insertVehicleInfo(vehicleInfo); + syncCarCount++; + } + } + + + log.info("鎴愬姛鍚屾{}涓狢MS杞﹁締淇℃伅", syncCarCount); + log.info("CMS杞﹁締淇℃伅鍚屾瀹屾垚"); + } catch (Exception e) { + log.error("鍚屾CMS杞﹁締淇℃伅寮傚父", e); + } + } + + //瀵硅溅鐗屽鐞嗙殑閫氱敤鏂规硶 + private String getPlateNo(String plateNo){ + if (StringUtils.isNotEmpty(plateNo)) { + // 浠庤溅杈嗗悕绉颁腑鎻愬彇杞︾墝鍙凤紙鍋囪鏍煎紡涓�"鈽呰溅鐗屽彿锛堝湴鍖猴級"锛� + if(plateNo.contains("(")) { + plateNo = plateNo.replace("鈽�", "").replace("鈽�", "").split("\\(")[0]; + }else{ + plateNo = plateNo.replace("鈽�", "").replace("鈽�", "").split("锛�")[0]; + } + } + return plateNo; + } + + /** + * 鍚屾CMS杞﹁締浣嶇疆淇℃伅 + */ + public void syncVehicleLocation() { + log.info("寮�濮嬪悓姝MS杞﹁締浣嶇疆淇℃伅"); + try { + //鍏堣幏寰楁湰鍦癈MS涓婄殑鎵�鏈塁MS杞﹁締 + VehicleInfo query = new VehicleInfo(); + query.setPlatformCode("CMS"); + query.setStatus("0"); + List<VehicleInfo> localVehicles = vehicleInfoService.selectVehicleInfoList(query); + + // 鑾峰彇杞﹁締鏈�鏂颁綅缃俊鎭� + CmsVehicleLocationResponse response = cmsGpsCollectService.getVehicleLocation( + null,2,1,null,null); + + if (response.getResult() != 0 ) { + log.warn("鑾峰彇杞﹁締浣嶇疆淇℃伅澶辫触"); + return; + } + + List<CmsVehicleLocationResponse.VehicleLocation> cmsVehicles = response.getInfos(); + Double defaultZero = 0.0; + for(CmsVehicleLocationResponse.VehicleLocation vehicle:cmsVehicles){ + //涓庤溅杈嗕俊鎭繘琛屽尮閰嶏紝濡傛灉鍖归厤鎴愬姛锛屽垯淇濆瓨杞﹁締浣嶇疆淇℃伅 + //瀵硅溅鐗岃繘琛屽鐞� + String plateNo =this.getPlateNo(vehicle.getVi()); + + if (!localVehicles.stream().anyMatch(e->e.getVehicleNo().equals(plateNo))) { + continue; + } + VehicleInfo f= localVehicles.stream().filter(e->e.getVehicleNo().equals(plateNo)).findFirst().get(); + if(f==null){ + continue; + } + + // 鍒涘缓GPS璁板綍 + VehicleGps gps = new VehicleGps(); + gps.setVehicleId(f.getVehicleId()); + gps.setDeviceId(null); + gps.setLongitude(vehicle.getJd()/1000000); + gps.setLatitude(vehicle.getWd()/1000000); + gps.setSpeed(defaultZero); + gps.setVehicleNo(plateNo); + gps.setDirection(defaultZero); + gps.setAltitude(defaultZero); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String deviceTime=sdf.format(new Date(vehicle.getTm())); + gps.setDeviceReportTime(deviceTime); + gps.setPlatformProcessTime(sdf.format(new Date())); + + gps.setCreateTime(new Date()); + gps.setCollectTime(deviceTime); + + // 淇濆瓨GPS璁板綍 + vehicleGpsService.insertVehicleGps(gps); + } + + + } catch (Exception e) { + log.error("鍚屾杞﹁締浣嶇疆淇℃伅寮傚父", e); + } + + + + + + } +} \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GpsSyncTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GpsSyncTask.java index 8c7c1ee..70b8789 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GpsSyncTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/GpsSyncTask.java @@ -99,12 +99,16 @@ VehicleInfo vehicleInfo = vehicleInfoService.selectVehicleInfoByPlateNumber(plateNumber); if (vehicleInfo != null) { vehicleInfo.setDeviceId(deviceId); + //鑾峰緱鏁版嵁瀛楀吀涓殑骞冲彴缂栫爜 + + vehicleInfo.setPlatformCode("GPS51"); vehicleInfoService.updateVehicleInfo(vehicleInfo); } else { VehicleInfo newVehicle = new VehicleInfo(); newVehicle.setVehicleNo(plateNumber); newVehicle.setDeviceId(deviceId); newVehicle.setStatus("0"); + newVehicle.setPlatformCode("GPS51"); vehicleInfoService.insertVehicleInfo(newVehicle); } } @@ -142,21 +146,39 @@ //devicetime 杩欎釜鏄竴涓猯inux鏃堕棿鎴筹紝瑕佽浆鎹㈡垚鍖椾含鏃堕棿锛屽啀杞垚yyyy-MM-dd HH:mm:ss鏍煎紡 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - + + //getArrivedtime 杩欎釜鏄竴涓猯inux鏃堕棿鎴筹紝瑕佽浆鎹㈡垚鍖椾含鏃堕棿锛屽啀杞垚yyyy-MM-dd HH:mm:ss鏍煎紡 + long arrivedTime = position.getArrivedtime(); + Date arrivedDate; + // 妫�鏌ユ椂闂存埑鏄惁鏈夋晥锛堝ぇ浜�0锛� + if (arrivedTime > 0) { + arrivedDate = new Date(arrivedTime); + // 鍑忓幓8灏忔椂 + arrivedDate.setTime(arrivedDate.getTime() - 8 * 60 * 60 * 1000); + } else { + // 鏃堕棿鎴虫棤鏁堬紝浣跨敤褰撳墠鏃堕棿 + arrivedDate = new Date(); + } + gps.setPlatformProcessTime(sdf.format(arrivedDate)); + // 璁惧涓婃姤鏃堕棿 long deviceTime = position.getDevicetime(); - if (deviceTime > 0 && deviceTime < 4102444800L) { // 2100-01-01 00:00:00 - gps.setDeviceReportTime(sdf.format(new Date(deviceTime * 1000L))); + Date date; + // 妫�鏌ユ椂闂存埑鏄惁鏈夋晥锛堝ぇ浜�0锛� + if (deviceTime > 0) { + date = new Date(deviceTime); + // 鍑忓幓8灏忔椂 + date.setTime(date.getTime() - 8 * 60 * 60 * 1000); } else { - log.warn("杞﹁締[{}]鐨勮澶囨椂闂存埑[{}]鏃犳晥锛屼娇鐢ㄥ綋鍓嶆椂闂�", vehicle.getVehicleNo(), deviceTime); - gps.setDeviceReportTime(sdf.format(new Date())); + // 鏃堕棿鎴虫棤鏁堬紝浣跨敤褰撳墠鏃堕棿 + date = arrivedDate; } - - // 骞冲彴澶勭悊鏃堕棿锛堝綋鍓嶆椂闂达級 - gps.setPlatformProcessTime(sdf.format(new Date())); + gps.setDeviceReportTime(sdf.format(date)); + + // 閲囬泦鏃堕棿锛堜娇鐢ㄨ澶囦笂鎶ユ椂闂达級 - gps.setCollectTime(gps.getDeviceReportTime()); + gps.setCollectTime(sdf.format(new Date( ))); // 淇濆瓨GPS浣嶇疆淇℃伅 vehicleGpsService.insertVehicleGps(gps); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsGpsLoginResponse.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsGpsLoginResponse.java new file mode 100644 index 0000000..d4c0552 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsGpsLoginResponse.java @@ -0,0 +1,56 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * CMS GPS鐧诲綍鍝嶅簲 + */ +public class CmsGpsLoginResponse { + /** 缁撴灉鐮� */ + @JsonProperty("result") + private Integer result; + + /** 浼氳瘽ID */ + @JsonProperty("jsession") + private String jsession; + + /** 璐︽埛鍚嶇О */ + @JsonProperty("account_name") + private String accountName; + + /** 浼氳瘽ID */ + @JsonProperty("JSESSIONID") + private String sessionId; + + public Integer getResult() { + return result; + } + + public void setResult(Integer result) { + this.result = result; + } + + public String getJsession() { + return jsession; + } + + public void setJsession(String jsession) { + this.jsession = jsession; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceListResponse.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceListResponse.java new file mode 100644 index 0000000..df25b7e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceListResponse.java @@ -0,0 +1,74 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; + +/** + * CMS杞﹁締璁惧鍒楄〃鏌ヨ鍝嶅簲 + */ +public class CmsVehicleDeviceListResponse implements Serializable { + private static final long serialVersionUID = 1L; + + /** 缁撴灉鐮� */ + @JsonProperty("result") + private Integer result; + + /** 璁惧鍒楄〃 */ + @JsonProperty("devices") + private List<VehicleDevice> devices; + + public Integer getResult() { + return result; + } + + public void setResult(Integer result) { + this.result = result; + } + + public List<VehicleDevice> getDevices() { + return devices; + } + + public void setDevices(List<VehicleDevice> devices) { + this.devices = devices; + } + + public static class VehicleDevice { + /** 杞︾墝鍙� */ + @JsonProperty("vid") + private String vehicleId; + + /** 璁惧绫诲瀷 */ + @JsonProperty("type") + private Integer type; + + /** 璁惧鍙� */ + @JsonProperty("did") + private String deviceId; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceResponse.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceResponse.java new file mode 100644 index 0000000..00fd638 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleDeviceResponse.java @@ -0,0 +1,223 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * CMS杞﹁締璁惧鏌ヨ鍝嶅簲 + */ +public class CmsVehicleDeviceResponse implements Serializable { + /** 缁撴灉鐮� */ + @JsonProperty("result") + private Integer result; + + /** 杞﹁締鍒楄〃 */ + @JsonProperty("vehicles") + private List<Vehicle> vehicles; + + public Integer getResult() { + return result; + } + + public void setResult(Integer result) { + this.result = result; + } + + public List<Vehicle> getVehicles() { + return vehicles; + } + + public void setVehicles(List<Vehicle> vehicles) { + this.vehicles = vehicles; + } + + @Data + public class Vehicle implements Serializable{ + /** 杞﹁締ID */ + @JsonProperty("id") + private Integer id; + + /** 杞﹁締鍚嶇О */ + @JsonProperty("nm") + private String nm; + + /** 鍥炬爣 */ + @JsonProperty("ic") + private Integer ic; + + /** 鐖剁骇ID */ + @JsonProperty("pid") + private Integer pid; + + /** 鐖剁骇鍚嶇О */ + @JsonProperty("pnm") + private String parentName; + + /** 缂╁啓 */ + @JsonProperty("abbr") + private String abbreviation; + + + + /** 杞︾墝绫诲瀷 */ + @JsonProperty("pt") + private String pt; + + /** 杞﹁締棰滆壊 */ + @JsonProperty("vehiColor") + private String vehicleColor; + + /** 鐘舵�� */ + @JsonProperty("status") + private Integer status; + + /** 杞﹁締鍝佺墝 */ + @JsonProperty("vehiBand") + private String vehicleBrand; + + /** 杞﹁締绫诲瀷 */ + @JsonProperty("vehiType") + private String vehicleType; + + /** 杞﹁締鐢ㄩ�� */ + @JsonProperty("vehiUse") + private String vehicleUse; + + /** 鐢熶骇鏃ユ湡 */ + @JsonProperty("dateProduct") + private Long productionDate; + + /** 閫氶亾鏁伴噺 */ + @JsonProperty("chnCount") + private Integer channelCount; + + /** 閫氶亾鍚嶇О */ + @JsonProperty("chnName") + private String channelName; + + /** 杈撳叆閫氶亾鏁伴噺 */ + @JsonProperty("ioInCount") + private Integer inputChannelCount; + + /** 杈撳叆閫氶亾鍚嶇О */ + @JsonProperty("ioInName") + private String inputChannelName; + + /** 杈撳嚭閫氶亾鏁伴噺 */ + @JsonProperty("ioOutCount") + private Integer outputChannelCount; + + /** 杈撳嚭閫氶亾鍚嶇О */ + @JsonProperty("ioOutName") + private String outputChannelName; + + /** 娓╁害閫氶亾鏁伴噺 */ + @JsonProperty("tempCount") + private Integer temperatureChannelCount; + + /** 娓╁害閫氶亾鍚嶇О */ + @JsonProperty("tempName") + private String temperatureChannelName; + + /** 鍙戝姩鏈哄彿 */ + @JsonProperty("engineNum") + private String engineNumber; + + /** 杞︽灦鍙� */ + @JsonProperty("frameNum") + private String frameNumber; + + /** 杞︿富濮撳悕 */ + @JsonProperty("ownerName") + private String ownerName; + + /** 鑱旂郴浜� */ + @JsonProperty("linkPeople") + private String contactPerson; + + /** 鑱旂郴鐢佃瘽 */ + @JsonProperty("linkPhone") + private String contactPhone; + + /** 璐拱鏃ユ湡 */ + @JsonProperty("datePurchase") + private Long purchaseDate; + + /** 骞存鏃ユ湡 */ + @JsonProperty("dateAnnualSurvey") + private Long annualSurveyDate; + + /** 闄愰�� */ + @JsonProperty("speedLimit") + private Integer speedLimit; + + /** 杩愯惀绾胯矾 */ + @JsonProperty("linesOperation") + private String operationLines; + + /** 琛屼笟 */ + @JsonProperty("industry") + private String industry; + + /** 杞﹀瀷 */ + @JsonProperty("carType") + private String carType; + + /** 杞﹁締浜у湴 */ + @JsonProperty("carPlace") + private String carPlace; + + /** 澶囨敞 */ + @JsonProperty("remark") + private String remark; + + /** 杞﹁締鍨嬪彿 */ + @JsonProperty("vehicleModel") + private String vehicleModel; + + /** 鍙戝姩鏈哄瀷鍙� */ + @JsonProperty("engineModel") + private String engineModel; + + /** 杞存暟 */ + @JsonProperty("axesNumber") + private Integer axesNumber; + + /** 鎬昏川閲� */ + @JsonProperty("totalWeight") + private Double totalWeight; + + /** 鍑嗙壍寮曡川閲� */ + @JsonProperty("quasiTractionMass") + private Double quasiTractionMass; + + /** 澶栧粨灏哄-闀� */ + @JsonProperty("longOutlineDimensions") + private Integer longOutlineDimensions; + + /** 澶栧粨灏哄-瀹� */ + @JsonProperty("wideOutlineDimensions") + private Integer wideOutlineDimensions; + + /** 澶栧粨灏哄-楂� */ + @JsonProperty("highOutlineDimensions") + private Integer highOutlineDimensions; + + /** 鍐呭粨灏哄-闀� */ + @JsonProperty("longInsideDimension") + private Integer longInsideDimension; + + /** 鍐呭粨灏哄-瀹� */ + @JsonProperty("wideInnerDimensions") + private Integer wideInnerDimensions; + + /** 鍐呭粨灏哄-楂� */ + @JsonProperty("highInsideDimensions") + private Integer highInsideDimensions; + + } + +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleLocationResponse.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleLocationResponse.java new file mode 100644 index 0000000..8305773 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/CmsVehicleLocationResponse.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * CMS杞﹁締浣嶇疆淇℃伅鏌ヨ鍝嶅簲 + */ +@Data +public class CmsVehicleLocationResponse implements Serializable { + private static final long serialVersionUID = 1L; + + /** 缁撴灉鐮� */ + @JsonProperty("result") + private Integer result; + + /** 浣嶇疆淇℃伅鍒楄〃 */ + @JsonProperty("infos") + private List<VehicleLocation> infos; + + /** 鍒嗛〉淇℃伅 */ + @JsonProperty("pagination") + private Pagination pagination; + + + @Data + public class VehicleLocation implements Serializable { + /** 杞︾墝鍙� */ + @JsonProperty("vi") + private String vi; + + /** 鏃堕棿鎴� */ + @JsonProperty("tm") + private Long tm; + + /** 缁忓害 */ + @JsonProperty("jd") + private Double jd; + + /** 绾害 */ + @JsonProperty("wd") + private Double wd; + + /** 鍦扮悊浣嶇疆 */ + @JsonProperty("pos") + private String pos; + + } + + @Data + public class Pagination implements Serializable{ + /** 鎬婚〉鏁� */ + @JsonProperty("totalPages") + private Integer totalPages; + + /** 褰撳墠椤� */ + @JsonProperty("currentPage") + private Integer currentPage; + + /** 姣忛〉璁板綍鏁� */ + @JsonProperty("pageRecords") + private Integer pageRecords; + + /** 鎬昏褰曟暟 */ + @JsonProperty("totalRecords") + private Integer totalRecords; + + /** 鎺掑簭鍙傛暟 */ + @JsonProperty("sortParams") + private String sortParams; + + /** 鏄惁鏈変笅涓�椤� */ + @JsonProperty("hasNextPage") + private Boolean hasNextPage; + + /** 鏄惁鏈変笂涓�椤� */ + @JsonProperty("hasPreviousPage") + private Boolean hasPreviousPage; + + /** 涓嬩竴椤� */ + @JsonProperty("nextPage") + private Integer nextPage; + + /** 涓婁竴椤� */ + @JsonProperty("previousPage") + private Integer previousPage; + + /** 璧峰璁板綍 */ + @JsonProperty("startRecord") + private Integer startRecord; + + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleInfo.java index ad3a522..b8aa771 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleInfo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleInfo.java @@ -38,6 +38,10 @@ @Excel(name = "鐘舵��", readConverterExp = "0=姝e父,1=鍋滅敤") private String status; + /** 骞冲彴鏍囪瘑 */ + @Excel(name = "骞冲彴鏍囪瘑") + private String platformCode; + public void setVehicleId(Long vehicleId) { this.vehicleId = vehicleId; } @@ -94,6 +98,14 @@ return status; } + public String getPlatformCode() { + return platformCode; + } + + public void setPlatformCode(String platformCode) { + this.platformCode = platformCode; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) @@ -104,6 +116,7 @@ .append("vehicleBrand", getVehicleBrand()) .append("vehicleModel", getVehicleModel()) .append("status", getStatus()) + .append("platformCode", getPlatformCode()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ICmsGpsCollectService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ICmsGpsCollectService.java new file mode 100644 index 0000000..782d0b0 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ICmsGpsCollectService.java @@ -0,0 +1,47 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.CmsGpsLoginResponse; +import com.ruoyi.system.domain.CmsVehicleDeviceResponse; +import com.ruoyi.system.domain.CmsVehicleDeviceListResponse; +import com.ruoyi.system.domain.CmsVehicleLocationResponse; + +/** + * CMS GPS閲囬泦鏈嶅姟鎺ュ彛 + */ +public interface ICmsGpsCollectService { + /** + * 鐧诲綍CMS绯荤粺 + * + * @param username 鐢ㄦ埛鍚� + * @param password 瀵嗙爜 + * @return 鐧诲綍鍝嶅簲 + */ + CmsGpsLoginResponse login(String username, String password); + + /** + * 鏌ヨ杞﹁締璁惧淇℃伅 + * + * @return 杞﹁締璁惧鍝嶅簲 + */ + CmsVehicleDeviceResponse queryVehicleDevices(); + + /** + * 鑾峰彇杞﹁締璁惧鍒楄〃 + * + * @param vehicleId 杞︾墝鍙凤紝澶氫釜浠ラ�楀彿鍒嗛殧 + * @return 杞﹁締璁惧鍒楄〃鍝嶅簲 + */ + CmsVehicleDeviceListResponse getDeviceByVehicle(String vehicleId); + + /** + * 鑾峰彇杞﹁締鏈�鏂颁綅缃俊鎭� + * + * @param vehicleId 杞︾墝鍙凤紝澶氫釜浠ラ�楀彿鍒嗛殧 + * @param toMap 鍦板浘缁忕含搴﹁浆鎹紙1锛氳胺姝屽湴鍥撅紝2锛氱櫨搴﹀湴鍥撅級 + * @param geoAddress 鏄惁瑙f瀽鍦扮悊浣嶇疆锛�1锛氭槸锛� + * @param currentPage 褰撳墠椤电爜 + * @param pageRecords 姣忛〉璁板綍鏁� + * @return 杞﹁締浣嶇疆淇℃伅鍝嶅簲 + */ + CmsVehicleLocationResponse getVehicleLocation(String vehicleId, Integer toMap, Integer geoAddress, Integer currentPage, Integer pageRecords); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java new file mode 100644 index 0000000..493f47d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CmsGpsCollectServiceImpl.java @@ -0,0 +1,199 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.utils.HttpUtil; +import com.ruoyi.common.utils.http.HttpUtils; +import com.ruoyi.system.domain.CmsGpsLoginResponse; +import com.ruoyi.system.domain.CmsVehicleDeviceResponse; +import com.ruoyi.system.domain.CmsVehicleDeviceListResponse; +import com.ruoyi.system.domain.CmsVehicleLocationResponse; +import com.ruoyi.system.domain.SysGpsConfig; +import com.ruoyi.system.service.ICmsGpsCollectService; +import com.ruoyi.system.service.IGpsConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.alibaba.fastjson.JSONObject; +import java.util.Date; + +/** + * CMS GPS閲囬泦鏈嶅姟瀹炵幇 + */ +@Service +public class CmsGpsCollectServiceImpl implements ICmsGpsCollectService { + private static final Logger log = LoggerFactory.getLogger(CmsGpsCollectServiceImpl.class); + + @Autowired + private IGpsConfigService gpsConfigService; + + @Override + public CmsGpsLoginResponse login(String username, String password) { + try { + // 浠庢暟鎹簱鑾峰彇CMS閰嶇疆 + SysGpsConfig baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + if (baseUrlConfig == null) { + throw new RuntimeException("鏈厤缃瓹MS绯荤粺鍦板潃"); + } + + + // 鍙戦�佺櫥褰曡姹� + String response = HttpUtil.get(baseUrlConfig.getDomain() + "/StandardApiAction_login.action?account=" + username + "&password=" + password,null); + + // 瑙f瀽鍝嶅簲 + CmsGpsLoginResponse loginResponse = JSONObject.parseObject(response, CmsGpsLoginResponse.class); + + if (loginResponse.getResult() == 0) { + log.info("CMS绯荤粺鐧诲綍鎴愬姛锛岀敤鎴凤細{}", username); + // 淇濆瓨浼氳瘽ID鍒伴厤缃〃 + baseUrlConfig.setToken(loginResponse.getJsession()); + // 璁剧疆token杩囨湡鏃堕棿涓�20灏忔椂 + baseUrlConfig.setTokenExpireTime(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 20)); + + gpsConfigService.updateGpsConfig(baseUrlConfig); + } else { + log.error("CMS绯荤粺鐧诲綍澶辫触,url:{},user:{},password:{},response:{}", baseUrlConfig.getDomain(), username, password, response); + } + + return loginResponse; + } catch (Exception e) { + log.error("CMS绯荤粺鐧诲綍寮傚父", e); + throw new RuntimeException("CMS绯荤粺鐧诲綍寮傚父锛�" + e.getMessage()); + } + } + + @Override + public CmsVehicleDeviceResponse queryVehicleDevices() { + try { + // 浠庢暟鎹簱鑾峰彇CMS閰嶇疆 + SysGpsConfig baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + if (baseUrlConfig == null) { + throw new RuntimeException("鏈厤缃瓹MS绯荤粺鍦板潃"); + } + + // 妫�鏌oken鏄惁杩囨湡 + if (baseUrlConfig.getTokenExpireTime() == null || + baseUrlConfig.getTokenExpireTime().before(new Date())) { + // token杩囨湡锛岄噸鏂扮櫥褰� + login(baseUrlConfig.getUsername(), baseUrlConfig.getPassword()); + baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + } + + // 鍙戦�佹煡璇㈣姹� + String response = HttpUtil.get(baseUrlConfig.getDomain() + "/StandardApiAction_queryUserVehicle.action?jsession=" + baseUrlConfig.getToken(),null); + + // 瑙f瀽鍝嶅簲 + CmsVehicleDeviceResponse deviceResponse = JSONObject.parseObject(response, CmsVehicleDeviceResponse.class); + + if (deviceResponse.getResult() == 0) { + log.info("鏌ヨ杞﹁締璁惧淇℃伅鎴愬姛锛屽叡{}鏉¤褰�", deviceResponse.getVehicles().size()); + } else { + log.error("鏌ヨ杞﹁締璁惧淇℃伅澶辫触"); + } + + return deviceResponse; + } catch (Exception e) { + log.error("鏌ヨ杞﹁締璁惧淇℃伅寮傚父", e); + throw new RuntimeException("鏌ヨ杞﹁締璁惧淇℃伅寮傚父锛�" + e.getMessage()); + } + } + + @Override + public CmsVehicleDeviceListResponse getDeviceByVehicle(String vehicleId) { + try { + // 浠庢暟鎹簱鑾峰彇CMS閰嶇疆 + SysGpsConfig baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + if (baseUrlConfig == null) { + throw new RuntimeException("鏈厤缃瓹MS绯荤粺鍦板潃"); + } + + // 妫�鏌oken鏄惁杩囨湡 + if (baseUrlConfig.getTokenExpireTime() == null || + baseUrlConfig.getTokenExpireTime().before(new Date())) { + // token杩囨湡锛岄噸鏂扮櫥褰� + login(baseUrlConfig.getUsername(), baseUrlConfig.getPassword()); + baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + } + + // 鏋勫缓璇锋眰URL + String url = baseUrlConfig.getDomain() + "/StandardApiAction_getDeviceByVehicle.action?jsession=" + baseUrlConfig.getToken(); + if (vehicleId != null && !vehicleId.isEmpty()) { + url += "&vehiIdno=" + vehicleId; + } + + // 鍙戦�佹煡璇㈣姹� + String response = HttpUtil.get(url,null); + + // 瑙f瀽鍝嶅簲 + CmsVehicleDeviceListResponse deviceListResponse = JSONObject.parseObject(response, CmsVehicleDeviceListResponse.class); + + if (deviceListResponse.getResult() == 0) { + log.info("鑾峰彇杞﹁締璁惧鍒楄〃鎴愬姛锛岃溅鐗屽彿锛歿}", vehicleId); + } else { + log.error("鑾峰彇杞﹁締璁惧鍒楄〃澶辫触锛岃溅鐗屽彿锛歿}", vehicleId); + } + + return deviceListResponse; + } catch (Exception e) { + log.error("鑾峰彇杞﹁締璁惧鍒楄〃寮傚父锛岃溅鐗屽彿锛歿}", vehicleId, e); + throw new RuntimeException("鑾峰彇杞﹁締璁惧鍒楄〃寮傚父锛�" + e.getMessage()); + } + } + + @Override + public CmsVehicleLocationResponse getVehicleLocation(String vehicleId, Integer toMap, Integer geoAddress, Integer currentPage, Integer pageRecords) { + try { + // 浠庢暟鎹簱鑾峰彇CMS閰嶇疆 + SysGpsConfig baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + if (baseUrlConfig == null) { + throw new RuntimeException("鏈厤缃瓹MS绯荤粺鍦板潃"); + } + + // 妫�鏌oken鏄惁杩囨湡 + if (baseUrlConfig.getTokenExpireTime() == null || + baseUrlConfig.getTokenExpireTime().before(new Date())) { + // token杩囨湡锛岄噸鏂扮櫥褰� + login(baseUrlConfig.getUsername(), baseUrlConfig.getPassword()); + baseUrlConfig = gpsConfigService.selectGpsConfigByKey("gpscms"); + } + + // 鏋勫缓璇锋眰URL + StringBuilder url = new StringBuilder(); + url.append(baseUrlConfig.getDomain()) + .append("/StandardApiAction_vehicleStatus.action?jsession=") + .append(baseUrlConfig.getToken()); + + if (vehicleId != null && !vehicleId.isEmpty()) { + url.append("&vehiIdno=").append(vehicleId); + } + if (toMap != null) { + url.append("&toMap=").append(toMap); + } + if (geoAddress != null) { + url.append("&geoaddress=").append(geoAddress); + } + if (currentPage != null) { + url.append("¤tPage=").append(currentPage); + } + if (pageRecords != null) { + url.append("&pageRecords=").append(pageRecords); + } + + // 鍙戦�佹煡璇㈣姹� + String response = HttpUtils.sendGet(url.toString()); + + // 瑙f瀽鍝嶅簲 + CmsVehicleLocationResponse locationResponse = JSONObject.parseObject(response, CmsVehicleLocationResponse.class); + + if (locationResponse.getResult() == 0) { + log.info("鑾峰彇杞﹁締浣嶇疆淇℃伅鎴愬姛锛岃溅鐗屽彿锛歿}", vehicleId); + } else { + log.error("鑾峰彇杞﹁締浣嶇疆淇℃伅澶辫触锛岃溅鐗屽彿锛歿}", vehicleId); + } + + return locationResponse; + } catch (Exception e) { + log.error("鑾峰彇杞﹁締浣嶇疆淇℃伅寮傚父锛岃溅鐗屽彿锛歿}", vehicleId, e); + throw new RuntimeException("鑾峰彇杞﹁締浣嶇疆淇℃伅寮傚父锛�" + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml index fada6a4..aa34be7 100644 --- a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml @@ -4,23 +4,24 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.VehicleInfoMapper"> - <resultMap type="VehicleInfo" id="VehicleInfoResult"> - <result property="vehicleId" column="vehicle_id" /> - <result property="deviceId" column="device_id" /> - <result property="vehicleNo" column="vehicle_no" /> - <result property="vehicleType" column="vehicle_type" /> - <result property="vehicleBrand" column="vehicle_brand" /> - <result property="vehicleModel" column="vehicle_model" /> - <result property="status" column="status" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - <result property="remark" column="remark" /> + <resultMap type="com.ruoyi.system.domain.VehicleInfo" id="VehicleInfoResult"> + <id property="vehicleId" column="vehicle_id" /> + <result property="deviceId" column="device_id" /> + <result property="vehicleNo" column="vehicle_no" /> + <result property="vehicleType" column="vehicle_type" /> + <result property="vehicleBrand" column="vehicle_brand" /> + <result property="vehicleModel" column="vehicle_model" /> + <result property="status" column="status" /> + <result property="platformCode" column="platform_code" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="remark" column="remark" /> </resultMap> <sql id="selectVehicleInfoVo"> - select vehicle_id, device_id, vehicle_no, vehicle_type, vehicle_brand, vehicle_model, status, create_by, create_time, update_by, update_time, remark + select vehicle_id, device_id, vehicle_no, vehicle_type, vehicle_brand, vehicle_model, status, platform_code, create_by, create_time, update_by, update_time, remark from tb_vehicle_info </sql> @@ -33,6 +34,7 @@ <if test="vehicleBrand != null and vehicleBrand != ''"> and vehicle_brand = #{vehicleBrand}</if> <if test="vehicleModel != null and vehicleModel != ''"> and vehicle_model = #{vehicleModel}</if> <if test="status != null and status != ''"> and status = #{status}</if> + <if test="platformCode != null and platformCode != ''"> and platform_code = #{platformCode}</if> </where> </select> @@ -55,6 +57,7 @@ <if test="vehicleBrand != null">vehicle_brand,</if> <if test="vehicleModel != null">vehicle_model,</if> <if test="status != null">status,</if> + <if test="platformCode != null">platform_code,</if> <if test="createBy != null">create_by,</if> <if test="createTime != null">create_time,</if> <if test="updateBy != null">update_by,</if> @@ -68,6 +71,7 @@ <if test="vehicleBrand != null">#{vehicleBrand},</if> <if test="vehicleModel != null">#{vehicleModel},</if> <if test="status != null">#{status},</if> + <if test="platformCode != null">#{platformCode},</if> <if test="createBy != null">#{createBy},</if> <if test="createTime != null">#{createTime},</if> <if test="updateBy != null">#{updateBy},</if> @@ -85,8 +89,10 @@ <if test="vehicleBrand != null">vehicle_brand = #{vehicleBrand},</if> <if test="vehicleModel != null">vehicle_model = #{vehicleModel},</if> <if test="status != null">status = #{status},</if> + <if test="platformCode != null">platform_code = #{platformCode},</if> <if test="updateBy != null">update_by = #{updateBy},</if> - update_time = sysdate() + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="remark != null">remark = #{remark},</if> </trim> where vehicle_id = #{vehicleId} </update> diff --git a/ruoyi-ui/src/views/system/gps/map.vue b/ruoyi-ui/src/views/system/gps/map.vue index c659550..f96f1a6 100644 --- a/ruoyi-ui/src/views/system/gps/map.vue +++ b/ruoyi-ui/src/views/system/gps/map.vue @@ -356,7 +356,6 @@ marker.setLabel(label); } else { // 缁堢偣鏄剧ず杞﹁締鍥炬爣 - const myIcon = new BMap.Icon( "/car_blue.png", new BMap.Size(20, 20), @@ -384,7 +383,6 @@ borderRadius: "3px", }); marker.setLabel(label); - // 鑾峰彇鍦板潃淇℃伅 const geoc = new BMap.Geocoder(); @@ -397,13 +395,14 @@ addComp.street + addComp.streetNumber; - // 娣诲姞淇℃伅绐楀彛 - const infoWindow = new BMap.InfoWindow( - `鏃堕棿锛�${item.collectTime}<br/>閫熷害锛�${ - item.speed - }km/h<br/>鏂瑰悜锛�${item.direction}掳<br/>鍦板潃锛�${address}` - ); + // 娣诲姞鐐瑰嚮浜嬩欢鐩戝惉鍣� marker.addEventListener("click", () => { + // 鍒涘缓淇℃伅绐楀彛 + const infoWindow = new BMap.InfoWindow( + `鏃堕棿锛�${currentSegment[index].collectTime}<br/>閫熷害锛�${ + currentSegment[index].speed + }km/h<br/>鏂瑰悜锛�${currentSegment[index].direction}掳<br/>鍦板潃锛�${address}` + ); this.map.openInfoWindow(infoWindow, bdPoint); }); }); @@ -475,12 +474,25 @@ }); marker.setLabel(label); - // 娣诲姞淇℃伅绐楀彛 - const infoWindow = new BMap.InfoWindow( - `鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${row.address}` - ); - marker.addEventListener("click", () => { - this.map.openInfoWindow(infoWindow, data.points[0]); + // 鑾峰彇鍦板潃淇℃伅 + const geoc = new BMap.Geocoder(); + geoc.getLocation(data.points[0], (rs) => { + const addComp = rs.addressComponents; + const address = + addComp.province + + addComp.city + + addComp.district + + addComp.street + + addComp.streetNumber; + + // 娣诲姞鐐瑰嚮浜嬩欢鐩戝惉鍣� + marker.addEventListener("click", () => { + // 鍒涘缓淇℃伅绐楀彛 + const infoWindow = new BMap.InfoWindow( + `鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${address}` + ); + this.map.openInfoWindow(infoWindow, data.points[0]); + }); }); // 淇濆瓨褰撳墠鏍囪鐐瑰紩鐢� diff --git a/ruoyi-ui/src/views/system/vehicle/index.vue b/ruoyi-ui/src/views/system/vehicle/index.vue index dd8660a..4ec9201 100644 --- a/ruoyi-ui/src/views/system/vehicle/index.vue +++ b/ruoyi-ui/src/views/system/vehicle/index.vue @@ -31,8 +31,12 @@ </el-form-item> <el-form-item label="骞冲彴鏍囪瘑" prop="platformCode"> <el-select v-model="queryParams.platformCode" placeholder="璇烽�夋嫨骞冲彴" clearable size="small"> - <el-option label="A骞冲彴" value="A" /> - <el-option label="B骞冲彴" value="B" /> + <el-option + v-for="dict in dict.type.sys_platform" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> </el-select> </el-form-item> <el-form-item> @@ -153,9 +157,13 @@ <el-input v-model="form.vehicleModel" placeholder="璇疯緭鍏ヨ溅杈嗗瀷鍙�" /> </el-form-item> <el-form-item label="骞冲彴鏍囪瘑" prop="platformCode"> - <el-select v-model="form.platformCode" placeholder="璇烽�夋嫨骞冲彴"> - <el-option label="A骞冲彴" value="A" /> - <el-option label="B骞冲彴" value="B" /> + <el-select v-model="form.platformCode" placeholder="璇烽�夋嫨骞冲彴" clearable> + <el-option + v-for="dict in dict.type.sys_platform" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> </el-select> </el-form-item> <el-form-item label="鐘舵��" prop="status"> @@ -217,7 +225,16 @@ platformCode: null }, // 琛ㄥ崟鍙傛暟 - form: {}, + form: { + vehicleId: null, + vehicleNo: null, + vehicleType: null, + vehicleBrand: null, + vehicleModel: null, + status: "0", + remark: null, + platformCode: null + }, // 琛ㄥ崟鏍¢獙 rules: { vehicleNo: [ @@ -225,6 +242,9 @@ ], status: [ { required: true, message: "鐘舵�佷笉鑳戒负绌�", trigger: "change" } + ], + platformCode: [ + { required: true, message: "骞冲彴鏍囪瘑涓嶈兘涓虹┖", trigger: "change" } ] } }; diff --git a/sql/cms_vehicle_sync_job.sql b/sql/cms_vehicle_sync_job.sql new file mode 100644 index 0000000..fad1a57 --- /dev/null +++ b/sql/cms_vehicle_sync_job.sql @@ -0,0 +1,30 @@ +-- 娣诲姞CMS杞﹁締鍚屾瀹氭椂浠诲姟 +INSERT INTO sys_job (job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark) +VALUES ( + 'CMS杞﹁締鍚屾浠诲姟', -- 浠诲姟鍚嶇О + 'DEFAULT', -- 浠诲姟缁勫悕 + 'cmsVehicleSyncTask.syncVehicleInfo()', -- 璋冪敤鐩爣瀛楃涓� + '0 0/30 * * * ?', -- 姣�30鍒嗛挓鎵ц涓�娆� + '3', -- 璁″垝鎵ц绛栫暐锛�3=涓嶈Е鍙戠珛鍗虫墽琛岋級 + '1', -- 鏄惁骞跺彂鎵ц锛�1=绂佹锛� + '0', -- 鐘舵�侊紙0=姝e父锛� + 'admin', -- 鍒涘缓鑰� + sysdate(), -- 鍒涘缓鏃堕棿 + 'CMS杞﹁締淇℃伅鍚屾瀹氭椂浠诲姟' -- 澶囨敞 +); + + +-- 娣诲姞CMS杞﹁締鍚屾瀹氭椂浠诲姟 +INSERT INTO sys_job (job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark) +VALUES ( + 'CMS杞﹁締鍚屾GPS', -- 浠诲姟鍚嶇О + 'DEFAULT', -- 浠诲姟缁勫悕 + 'cmsVehicleSyncTask.syncVehicleLocation()', -- 璋冪敤鐩爣瀛楃涓� + '0 0/30 * * * ?', -- 姣�30鍒嗛挓鎵ц涓�娆� + '3', -- 璁″垝鎵ц绛栫暐锛�3=涓嶈Е鍙戠珛鍗虫墽琛岋級 + '1', -- 鏄惁骞跺彂鎵ц锛�1=绂佹锛� + '0', -- 鐘舵�侊紙0=姝e父锛� + 'admin', -- 鍒涘缓鑰� + sysdate(), -- 鍒涘缓鏃堕棿 + 'CMS杞﹁締GPS閲囬泦' -- 澶囨敞 +); \ No newline at end of file -- Gitblit v1.9.1