电子围栏
This commit is contained in:
		| @ -83,6 +83,8 @@ public class ZcElectronicFenceController extends BaseController | ||||
|     { | ||||
|         ZcRentCarRule zcRentCarRule = new ZcRentCarRule(); | ||||
|         zcRentCarRule.setStatus("0"); | ||||
|         // 查询未绑定电子围栏套餐 | ||||
|         zcRentCarRule.setExtend1("0"); | ||||
|         List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule); | ||||
|         mmap.put("rentCarRuleList", rentCarRuleList); | ||||
|         return prefix + "/add"; | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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<Long> ids, @Param("fenceId") Long fenceId); | ||||
|     /** | ||||
|      * 根据电子围栏id 取消与套餐绑定 | ||||
|      * @param fenceId | ||||
|      * @return | ||||
|      */ | ||||
|     public int updateZcRentCarRuleUnbindFence(@Param("fenceId") Long fenceId); | ||||
| } | ||||
|  | ||||
| @ -51,6 +51,19 @@ public interface IZcRentCarRuleService | ||||
|      */ | ||||
|     public int updateZcRentCarRule(List<Long> carModelIds, ZcRentCarRule zcRentCarRule); | ||||
|  | ||||
|     /** | ||||
|      * 根据套餐ids绑定电子围栏 | ||||
|      * @param rentCarRuleIds | ||||
|      * @return | ||||
|      */ | ||||
|     public int updateZcRentCarRuleBindFence(List<Long> rentCarRuleIds,Long fenceId); | ||||
|     /** | ||||
|      * 根据电子围栏id 取消与套餐绑定 | ||||
|      * @param fenceId | ||||
|      * @return | ||||
|      */ | ||||
|     public int updateZcRentCarRuleUnbindFence(Long fenceId); | ||||
|  | ||||
|     /** | ||||
|      * 批量删除租车计费规则 | ||||
|      *  | ||||
|  | ||||
| @ -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<ZcElectronicFenceRule> 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); | ||||
|  | ||||
| @ -92,6 +92,9 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService | ||||
|     { | ||||
|         ZcRentCarRule zcRentCarRule = new ZcRentCarRule(); | ||||
|         zcRentCarRule.setStatus("0"); | ||||
|         // 查询未绑定电子围栏套餐  和 当前绑定的套餐 | ||||
|         zcRentCarRule.setQueryFenceRule("0"); | ||||
|         zcRentCarRule.setExtend1(fenceId.toString()); | ||||
|         List<ZcRentCarRule> 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<Long> rentCarRuleIds,Long fenceId) { | ||||
|         return zcRentCarRuleMapper.updateZcRentCarRuleBindFence(rentCarRuleIds,fenceId); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int updateZcRentCarRuleUnbindFence(Long fenceId) { | ||||
|         return zcRentCarRuleMapper.updateZcRentCarRuleUnbindFence(fenceId); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 批量删除租车计费规则 | ||||
|      *  | ||||
|  | ||||
| @ -57,6 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|             <if test="operatingCompanyId != null  and operatingCompanyId != ''"> and a.operating_company_id = #{operatingCompanyId}</if> | ||||
|             <if test="status != null  and status != ''"> and a.status = #{status}</if> | ||||
|             <if test="isDefault != null  and isDefault != ''"> and a.is_default = #{isDefault}</if> | ||||
|             <if test="extend1 != null and extend1 != '' and queryFenceRule == null"> and a.extend1 = #{extend1}</if> | ||||
|             <if test="queryFenceRule != null and queryFenceRule != '' and queryFenceRule == 0 "> | ||||
|                 and (a.extend1 = '0' OR a.extend1 = #{extend1}) | ||||
|              </if> | ||||
|         </where> | ||||
|         order by a.update_time desc | ||||
|     </select> | ||||
| @ -158,6 +162,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|         </trim> | ||||
|         where id = #{id} | ||||
|     </update> | ||||
|     <update id="updateZcRentCarRuleBindFence"> | ||||
|         update zc_rent_car_rule set extend1 = #{fenceId} where id in | ||||
|         <foreach item="id" collection="ids" open="(" separator="," close=")"> | ||||
|             #{id} | ||||
|         </foreach> | ||||
|     </update> | ||||
|     <update id="updateZcRentCarRuleUnbindFence"> | ||||
|          update zc_rent_car_rule set extend1 = '0' where extend1 = #{fenceId}  | ||||
|     </update> | ||||
|  | ||||
|     <delete id="deleteZcRentCarRuleById" parameterType="Long"> | ||||
|         delete from zc_rent_car_rule where id = #{id} | ||||
|  | ||||
| @ -100,6 +100,7 @@ | ||||
|                     </div> | ||||
|                     <p>提示:<br/> | ||||
|                         绘制:鼠标左键点击及移动即可绘制图形<br/> | ||||
|                         撤销:鼠标右键点击撤销<br/> | ||||
|                         结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/> | ||||
|                     </p> | ||||
|                 </div> | ||||
| @ -350,4 +351,4 @@ | ||||
|         window.onload = initMap; | ||||
|     </script> | ||||
| </body> | ||||
| </html> | ||||
| </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'); | ||||
|         } | ||||
|     </style> | ||||
| </head> | ||||
| @ -93,13 +77,15 @@ | ||||
|                 <div class="col-sm-8"> | ||||
|                     <div id="container"  class="map-container"></div> | ||||
|                     <div id="toolControl"> | ||||
|                         <div class="toolItem active" id="polygon" title="多边形"></div> | ||||
|                         <!--                        <div class="toolItem active" id="polygon"  title="多边形"></div> --> | ||||
|                         <!--                        <div class="toolItem" id="delete" onclick="editor.delete();" title="删除"></div> --> | ||||
|                         <!--                        <div class="toolItem" id="circle" title="圆形"></div>--> | ||||
|                         <!--                        <div class="toolItem" id="rectangle" title="矩形"></div>--> | ||||
|                         <!--                        <div class="toolItem" id="ellipse" title="椭圆"></div>--> | ||||
|                     </div> | ||||
|                     <p>提示:<br/> | ||||
|                         绘制:鼠标左键点击及移动即可绘制图形<br/> | ||||
|                         撤销:鼠标右键点击撤销<br/> | ||||
|                         结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/> | ||||
|                     </p> | ||||
|  | ||||
| @ -108,7 +94,7 @@ | ||||
|             <div class="form-group"> | ||||
|                 <label class="col-sm-2 control-label">围栏坐标地址:</label> | ||||
|                 <div class="col-sm-8"> | ||||
|                     <textarea name="address" class="form-control">[[*{address}]]</textarea> | ||||
|                     <textarea id="address" name="address" class="form-control">[[*{address}]]</textarea> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <h4 class="form-header h4">关联套餐</h4> | ||||
| @ -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; | ||||
|  | ||||
|     </script> | ||||
| </body> | ||||
| </html> | ||||
| </html> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 majian314
					majian314