From 8d94b3c30b7d91a67d65cc6b0a3ad42b85055eb5 Mon Sep 17 00:00:00 2001 From: majian314 Date: Tue, 14 Oct 2025 11:59:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E5=AD=90=E5=9B=B4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ZcElectronicFenceController.java | 2 + .../ruoyi/operation/domain/ZcRentCarRule.java | 15 +- .../operation/mapper/ZcRentCarRuleMapper.java | 14 ++ .../service/IZcRentCarRuleService.java | 13 ++ .../impl/ZcElectronicFenceServiceImpl.java | 10 +- .../impl/ZcRentCarRuleServiceImpl.java | 13 ++ .../mapper/operation/ZcRentCarRuleMapper.xml | 13 ++ .../operation/electronicFence/add.html | 3 +- .../operation/electronicFence/edit.html | 142 +++++++++--------- 9 files changed, 145 insertions(+), 80 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcElectronicFenceController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcElectronicFenceController.java index d40fd27..b6ead33 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcElectronicFenceController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcElectronicFenceController.java @@ -83,6 +83,8 @@ public class ZcElectronicFenceController extends BaseController { ZcRentCarRule zcRentCarRule = new ZcRentCarRule(); zcRentCarRule.setStatus("0"); + // 查询未绑定电子围栏套餐 + zcRentCarRule.setExtend1("0"); List rentCarRuleList = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule); mmap.put("rentCarRuleList", rentCarRuleList); return prefix + "/add"; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcRentCarRule.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcRentCarRule.java index 930b1a8..7be9307 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcRentCarRule.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcRentCarRule.java @@ -74,7 +74,7 @@ public class ZcRentCarRule extends BaseEntity /** 删除标志(0代表存在 2代表删除) */ private String delFlag; - /** 扩展字段1 */ + /** 绑定电子围栏 */ private String extend1; /** 扩展字段2 */ @@ -96,7 +96,10 @@ public class ZcRentCarRule extends BaseEntity private boolean flag = false; @Transient private String operatingCompanyName; - + + @Transient + private String queryFenceRule; + public void setId(Long id) { this.id = id; @@ -304,6 +307,14 @@ public class ZcRentCarRule extends BaseEntity this.flag = flag; } + public String getQueryFenceRule() { + return queryFenceRule; + } + + public void setQueryFenceRule(String queryFenceRule) { + this.queryFenceRule = queryFenceRule; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java index 7c3aec9..b468ada 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.operation.mapper; import java.util.List; import com.ruoyi.operation.domain.ZcRentCarRule; +import org.apache.ibatis.annotations.Param; /** * 租车计费规则Mapper接口 @@ -59,4 +60,17 @@ public interface ZcRentCarRuleMapper * @return 结果 */ public int deleteZcRentCarRuleByIds(String[] ids); + + /** + * 根据套餐ids绑定电子围栏 + * @param ids + * @return + */ + public int updateZcRentCarRuleBindFence(@Param("ids") List ids, @Param("fenceId") Long fenceId); + /** + * 根据电子围栏id 取消与套餐绑定 + * @param fenceId + * @return + */ + public int updateZcRentCarRuleUnbindFence(@Param("fenceId") Long fenceId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java index e1bfd1d..e35826b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java @@ -51,6 +51,19 @@ public interface IZcRentCarRuleService */ public int updateZcRentCarRule(List carModelIds, ZcRentCarRule zcRentCarRule); + /** + * 根据套餐ids绑定电子围栏 + * @param rentCarRuleIds + * @return + */ + public int updateZcRentCarRuleBindFence(List rentCarRuleIds,Long fenceId); + /** + * 根据电子围栏id 取消与套餐绑定 + * @param fenceId + * @return + */ + public int updateZcRentCarRuleUnbindFence(Long fenceId); + /** * 批量删除租车计费规则 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcElectronicFenceServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcElectronicFenceServiceImpl.java index fe33057..ba570ff 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcElectronicFenceServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcElectronicFenceServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.operation.domain.ZcCarModelPackage; import com.ruoyi.operation.mapper.ZcElectronicFenceRuleMapper; +import com.ruoyi.operation.service.IZcRentCarRuleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -29,6 +30,8 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService private ZcElectronicFenceMapper zcElectronicFenceMapper; @Autowired private ZcElectronicFenceRuleMapper zcElectronicFenceRuleMapper; + @Autowired + private IZcRentCarRuleService zcRentCarRuleService; /** * 查询电子围栏 * @@ -77,8 +80,9 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService } if (!zcElectronicFenceRuleList.isEmpty()) { zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList); - } + zcRentCarRuleService.updateZcRentCarRuleBindFence(zcElectronicFence.getRentCarRuleIds(),zcElectronicFence.getId()); + } return rows; } @@ -94,7 +98,8 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService { zcElectronicFence.setUpdateTime(DateUtils.getNowDate()); zcElectronicFenceMapper.deleteZcElectronicFenceRuleByElectronicFenceId(zcElectronicFence.getId()); - + zcRentCarRuleService.updateZcRentCarRuleUnbindFence(zcElectronicFence.getId()); + // 保存关联表 ZcRentCarRuleBattery 数据 List zcElectronicFenceRuleList = new ArrayList<>(); for (Long rentCarRuleId : zcElectronicFence.getRentCarRuleIds()) { @@ -106,6 +111,7 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService } if (!zcElectronicFenceRuleList.isEmpty()) { zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList); + zcRentCarRuleService.updateZcRentCarRuleBindFence(zcElectronicFence.getRentCarRuleIds(), zcElectronicFence.getId()); } return zcElectronicFenceMapper.updateZcElectronicFence(zcElectronicFence); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java index 0be3010..554f0a6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java @@ -92,6 +92,9 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService { ZcRentCarRule zcRentCarRule = new ZcRentCarRule(); zcRentCarRule.setStatus("0"); + // 查询未绑定电子围栏套餐 和 当前绑定的套餐 + zcRentCarRule.setQueryFenceRule("0"); + zcRentCarRule.setExtend1(fenceId.toString()); List rentCarRuleList = zcRentCarRuleMapper.selectZcRentCarRuleList(zcRentCarRule); ZcElectronicFenceRule fenceRule = new ZcElectronicFenceRule(); fenceRule.setElectronicFenceId(fenceId); @@ -153,6 +156,16 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService return flag; } + @Override + public int updateZcRentCarRuleBindFence(List rentCarRuleIds,Long fenceId) { + return zcRentCarRuleMapper.updateZcRentCarRuleBindFence(rentCarRuleIds,fenceId); + } + + @Override + public int updateZcRentCarRuleUnbindFence(Long fenceId) { + return zcRentCarRuleMapper.updateZcRentCarRuleUnbindFence(fenceId); + } + /** * 批量删除租车计费规则 * diff --git a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml index d1af438..0a755ad 100644 --- a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml @@ -57,6 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.operating_company_id = #{operatingCompanyId} and a.status = #{status} and a.is_default = #{isDefault} + and a.extend1 = #{extend1} + + and (a.extend1 = '0' OR a.extend1 = #{extend1}) + order by a.update_time desc @@ -158,6 +162,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update zc_rent_car_rule set extend1 = #{fenceId} where id in + + #{id} + + + + update zc_rent_car_rule set extend1 = '0' where extend1 = #{fenceId} + delete from zc_rent_car_rule where id = #{id} diff --git a/ruoyi-admin/src/main/resources/templates/operation/electronicFence/add.html b/ruoyi-admin/src/main/resources/templates/operation/electronicFence/add.html index 464e995..7883b81 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/electronicFence/add.html +++ b/ruoyi-admin/src/main/resources/templates/operation/electronicFence/add.html @@ -100,6 +100,7 @@

提示:
绘制:鼠标左键点击及移动即可绘制图形
+ 撤销:鼠标右键点击撤销
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;

@@ -350,4 +351,4 @@ window.onload = initMap; - \ No newline at end of file + diff --git a/ruoyi-admin/src/main/resources/templates/operation/electronicFence/edit.html b/ruoyi-admin/src/main/resources/templates/operation/electronicFence/edit.html index 97eceba..9afa25e 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/electronicFence/edit.html +++ b/ruoyi-admin/src/main/resources/templates/operation/electronicFence/edit.html @@ -22,7 +22,7 @@ left: 0px; right: 0px; margin: auto; - width: 40px; + width: 90px; z-index: 1001; } @@ -50,28 +50,12 @@ background-color: #d5dff2; } - #marker { - background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/marker_editor.png'); - } - - #polyline { - background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polyline.png'); - } - #polygon { background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polygon.png'); } - #circle { - background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/circle.png'); - } - - #rectangle { - background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/rectangle.png'); - } - - #ellipse { - background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/ellipse.png'); + #delete { + background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/delete.png'); } @@ -93,13 +77,15 @@
-
+ +

提示:
绘制:鼠标左键点击及移动即可绘制图形
+ 撤销:鼠标右键点击撤销
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;

@@ -108,7 +94,7 @@
- +

关联套餐

@@ -268,83 +254,89 @@ } }); + // 转换函数 + function convertCoordinates(coordinates) { + return coordinates.map(coord => + `new TMap.LatLng(${coord.lat},${coord.lng})` + ).join(',\n'); + } + function initMap() { - var center = new TMap.LatLng(28.228302, 112.938901); + // 回显已存在的围栏数据 + var address = [[${zcElectronicFence.address}]]; + address = JSON.parse(address); + const simplePath = address.map(coord => new TMap.LatLng(coord.lat, coord.lng)); + + // 取第一个经纬度用于初始化地图中心位置 + var center; + if (simplePath.length > 0) { + center = simplePath[0]; + console.log('使用围栏第一个点作为中心:', center.lat, center.lng); + } else { + center = new TMap.LatLng(28.228302, 112.938901); + console.log('使用默认中心点:', center.lat, center.lng); + } map = new TMap.Map('container', { zoom: 12, center: center, }); // 初始化几何图形及编辑器 - var marker = new TMap.MultiMarker({ map: map }); - var polyline = new TMap.MultiPolyline({ map: map }); var polygon = new TMap.MultiPolygon({ map: map }); - var circle = new TMap.MultiCircle({ map: map }); - var rectangle = new TMap.MultiRectangle({ map: map }); - var ellipse = new TMap.MultiEllipse({ map: map }); editor = new TMap.tools.GeometryEditor({ map: map, overlayList: [ - { overlay: marker, id: 'marker' }, - { overlay: polyline, id: 'polyline' }, { overlay: polygon, id: 'polygon' }, - { overlay: circle, id: 'circle' }, - { overlay: rectangle, id: 'rectangle' }, - { overlay: ellipse, id: 'ellipse' }, ], actionMode: TMap.tools.constants.EDITOR_ACTION.DRAW, activeOverlayId: 'polygon', snappable: true, }); - - // 等待编辑器初始化完成后再回显数据 - setTimeout(function() { - echoExistingFence(polygon); - }, 500); - - // 监听绘制结束事件 - editor.on('draw_complete', (geometry) => { - var id = geometry.id; - if (editor.getActiveOverlay().id === 'polygon') { - var geo = polygon.geometries.filter(function (item) { - return item.id === id; - }); - console.log('绘制的多边形坐标:', geo[0].paths); - $("#address").val(JSON.stringify(geo[0].paths)); - } + + // 初始化几何图形及编辑器 + editor = new TMap.tools.GeometryEditor({ + map, // 编辑器绑定的地图对象 + overlayList: [ // 可编辑图层 + { + overlay: new TMap.MultiPolygon({ + map, + styles: { + highlight: new TMap.PolygonStyle({ + color: 'rgba(255, 255, 0, 0.6)' + }) + }, + geometries: [ + { + paths: simplePath + } + ] + }), + id: 'polygon', + selectedStyleId: 'highlight' + } + ], + actionMode: TMap.tools.constants.EDITOR_ACTION.INTERACT, // 编辑器的工作模式 + activeOverlayId: 'polygon', // 激活图层 + selectable: true, // 开启点选功能 + snappable: true // 开启吸附 }); + + + // 监听删除、修改完成事件 + let evtList = ['delete', 'adjust']; + evtList.forEach(evtName => { + editor.on(evtName + '_complete', evtResult => { + console.log(evtName, JSON.stringify(evtResult.paths)); + $("#address").val(JSON.stringify(evtResult.paths)); + }); + }); + } - function echoExistingFence(polygon) { - // 回显已存在的围栏数据 - var existingAddress = $("#address").val(); - console.log("existing address:", existingAddress); - - if (existingAddress && existingAddress.trim() !== "") { - try { - var paths = JSON.parse(existingAddress); - console.log("parsed paths:", paths); - - // 清除可能已存在的几何图形 - polygon.clear(); - - // 添加几何图形 - polygon.addGeometry({ - id: "existingPolygon", - styleId: "default", - paths: paths - }); - - console.log("围栏回显完成"); - } catch (e) { - console.error("解析围栏坐标数据失败:", e); - } - } - } // 初始化地图 window.onload = initMap; - \ No newline at end of file +