From 6cdcb8574acd982a7434426171f7427a79253d72 Mon Sep 17 00:00:00 2001 From: 19173159168 Date: Wed, 9 Jul 2025 22:53:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=9F=E8=BD=A6=E5=A5=97=E9=A4=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ZcRentCarRuleController.java | 44 ++++- .../mapper/ZcRentCarRuleBatteryMapper.java | 5 + .../service/IZcRentCarRuleBatteryService.java | 3 + .../impl/ZcRentCarRuleBatteryServiceImpl.java | 11 ++ .../operation/ZcRentCarRuleBatteryMapper.xml | 13 +- .../templates/operation/rentCarRule/add.html | 8 +- .../operation/rentCarRule/detail.html | 153 ++++++++++++++++++ .../templates/operation/rentCarRule/edit.html | 6 - .../operation/rentCarRule/rentCarRule.html | 10 +- 9 files changed, 226 insertions(+), 27 deletions(-) create mode 100644 ruoyi-admin/src/main/resources/templates/operation/rentCarRule/detail.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java index 3b64922..93a5876 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java @@ -1,20 +1,20 @@ package com.ruoyi.operation.controller; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Random; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.operation.domain.Company; +import com.ruoyi.operation.domain.ZcRentCarRuleBattery; import com.ruoyi.operation.service.ICompanyService; +import com.ruoyi.operation.service.IZcRentCarRuleBatteryService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.operation.domain.ZcRentCarRule; @@ -40,6 +40,9 @@ public class ZcRentCarRuleController extends BaseController private IZcRentCarRuleService zcRentCarRuleService; @Autowired private ICompanyService companyService; + @Autowired + private IZcRentCarRuleBatteryService zcRentCarRuleBatteryService; + @RequiresPermissions("operation:rentCarRule:view") @GetMapping() @@ -101,11 +104,26 @@ public class ZcRentCarRuleController extends BaseController @Log(title = "租车计费规则", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(ZcRentCarRule zcRentCarRule) + public AjaxResult addSave(@RequestParam("batteryRules") List batteryRuleIds, ZcRentCarRule zcRentCarRule) { zcRentCarRule.setRuleCode(generateTimestampBasedCode()); zcRentCarRule.setCreateBy(getLoginName()); - return toAjax(zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule)); + int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule); + + + // 保存关联表 ZcRentCarRuleBattery 数据 + List ruleBatteryList = new ArrayList<>(); + for (Long batteryRuleId : batteryRuleIds) { + ZcRentCarRuleBattery ruleBattery = new ZcRentCarRuleBattery(); + ruleBattery.setCarRuleId(zcRentCarRule.getId()); + ruleBattery.setBatteryRuleId(batteryRuleId); + ruleBattery.setCreateTime(new Date()); + ruleBatteryList.add(ruleBattery); + } + if (!ruleBatteryList.isEmpty()) { + zcRentCarRuleBatteryService.batchInsert(ruleBatteryList); + } + return toAjax(flag); } /** @@ -136,6 +154,18 @@ public class ZcRentCarRuleController extends BaseController return toAjax(zcRentCarRuleService.updateZcRentCarRule(zcRentCarRule)); } + @GetMapping("/detail/{id}") + public String detail(@PathVariable("id") Long id, ModelMap mmap) { + ZcRentCarRule zcRentCarRule = zcRentCarRuleService.selectZcRentCarRuleById(id); + mmap.put("zcRentCarRule", zcRentCarRule); + List companyList = companyService.getCompanyList(new Company(),getSysUser()); // 获取运营商列表 + mmap.put("companyList", companyList); // 将运营商列表传递到前端 + // 查询已绑定的电池规则ID列表 + List batteryRuleIds = zcRentCarRuleBatteryService.selectBatteryRuleIdsByCarRuleId(id); + mmap.put("selectedBatteryRuleIds", batteryRuleIds); + return prefix + "/detail"; + } + /** * 删除租车计费规则 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleBatteryMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleBatteryMapper.java index 829bea6..afcbefe 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleBatteryMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleBatteryMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.operation.mapper; import java.util.List; import com.ruoyi.operation.domain.ZcRentCarRuleBattery; +import org.apache.ibatis.annotations.Param; /** * 租车规则租电规则关联Mapper接口 @@ -27,6 +28,7 @@ public interface ZcRentCarRuleBatteryMapper */ public List selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery); + List selectBatteryRuleIdsByCarRuleId(Long carRuleId); /** * 新增租车规则租电规则关联 * @@ -58,4 +60,7 @@ public interface ZcRentCarRuleBatteryMapper * @return 结果 */ public int deleteZcRentCarRuleBatteryByIds(String[] ids); + + + int batchInsert(@Param("list") List ruleBatteryList); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleBatteryService.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleBatteryService.java index 3eacb5e..4d863d6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleBatteryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleBatteryService.java @@ -27,6 +27,7 @@ public interface IZcRentCarRuleBatteryService */ public List selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery); + List selectBatteryRuleIdsByCarRuleId(Long carRuleId); /** * 新增租车规则租电规则关联 * @@ -35,6 +36,8 @@ public interface IZcRentCarRuleBatteryService */ public int insertZcRentCarRuleBattery(ZcRentCarRuleBattery zcRentCarRuleBattery); + public int batchInsert(List zcRentCarRuleBatteryList); + /** * 修改租车规则租电规则关联 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleBatteryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleBatteryServiceImpl.java index 8b71eb1..e0a1dab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleBatteryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleBatteryServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.operation.service.impl; +import java.util.Collections; import java.util.List; import com.ruoyi.common.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +46,11 @@ public class ZcRentCarRuleBatteryServiceImpl implements IZcRentCarRuleBatterySer return zcRentCarRuleBatteryMapper.selectZcRentCarRuleBatteryList(zcRentCarRuleBattery); } + @Override + public List selectBatteryRuleIdsByCarRuleId(Long carRuleId) { + return zcRentCarRuleBatteryMapper.selectBatteryRuleIdsByCarRuleId(carRuleId); + } + /** * 新增租车规则租电规则关联 * @@ -58,6 +64,11 @@ public class ZcRentCarRuleBatteryServiceImpl implements IZcRentCarRuleBatterySer return zcRentCarRuleBatteryMapper.insertZcRentCarRuleBattery(zcRentCarRuleBattery); } + @Override + public int batchInsert(List zcRentCarRuleBatteryList) { + return zcRentCarRuleBatteryMapper.batchInsert(zcRentCarRuleBatteryList); + } + /** * 修改租车规则租电规则关联 * diff --git a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleBatteryMapper.xml b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleBatteryMapper.xml index 1e77ddf..b3e2b1a 100644 --- a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleBatteryMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleBatteryMapper.xml @@ -34,7 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + + insert into zc_rent_car_rule_battery @@ -88,4 +92,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + INSERT INTO zc_rent_car_rule_battery (car_rule_id, battery_rule_id,create_time) + VALUES + + (#{item.carRuleId}, #{item.batteryRuleId}, #{item.createTime}) + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html index 7379b8a..d0b37e9 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html +++ b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html @@ -12,12 +12,6 @@ -
- -
- -
-
@@ -156,7 +150,7 @@ $.get(prefix2 + '/list/byLeaseType', { leaseType: newRentalType }, function(data) { var html = ''; data.forEach(function(rule) { - html += `
`; + html += `
`; }); $('#batteryRuleList').html(html); }); diff --git a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/detail.html b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/detail.html new file mode 100644 index 0000000..c353359 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/detail.html @@ -0,0 +1,153 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+ +
+
+
+ +
+
+ + +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/edit.html b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/edit.html index 9aa60d5..f047d5e 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/edit.html +++ b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/edit.html @@ -13,12 +13,6 @@
-
- -
- -
-
diff --git a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/rentCarRule.html b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/rentCarRule.html index 2191d1f..b1354d2 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/rentCarRule.html +++ b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/rentCarRule.html @@ -97,6 +97,7 @@ url: prefix + "/list", createUrl: prefix + "/add", updateUrl: prefix + "/edit/{id}", + detailUrl: prefix + "/detail/{id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", modalName: "租车套餐", @@ -160,10 +161,6 @@ return $.table.selectDictLabel(autoDeductDatas, value); } }, - { - field: 'operatingCompanyId', - title: '关联电池套餐' - }, { field: 'status', title: '状态', @@ -180,13 +177,14 @@ align: 'center', formatter: function(value, row, index) { var actions = []; - // actions.push('编辑 '); + actions.push('编辑 '); actions.push('删除'); if (row.status == 1) { actions.push('启用 '); } else { actions.push('停用 '); } + actions.push(' 查看'); return actions.join(''); } }] @@ -195,7 +193,7 @@ }); /* 停用 */ - function disable(id,phone) { + function disable(id, phone) { $.modal.confirm("确认是否停用该套餐?此套餐停用后正在租用订单继续生效,续租订单继续以原订单为准", function() { $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 }); })