租车套餐

This commit is contained in:
19173159168
2025-07-09 22:53:20 +08:00
parent ed0c78bb13
commit 6cdcb8574a
9 changed files with 226 additions and 27 deletions

View File

@ -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<Long> batteryRuleIds, ZcRentCarRule zcRentCarRule)
{
zcRentCarRule.setRuleCode(generateTimestampBasedCode());
zcRentCarRule.setCreateBy(getLoginName());
return toAjax(zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule));
int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule);
// 保存关联表 ZcRentCarRuleBattery 数据
List<ZcRentCarRuleBattery> 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<Company> companyList = companyService.getCompanyList(new Company(),getSysUser()); // 获取运营商列表
mmap.put("companyList", companyList); // 将运营商列表传递到前端
// 查询已绑定的电池规则ID列表
List<Long> batteryRuleIds = zcRentCarRuleBatteryService.selectBatteryRuleIdsByCarRuleId(id);
mmap.put("selectedBatteryRuleIds", batteryRuleIds);
return prefix + "/detail";
}
/**
* 删除租车计费规则
*/

View File

@ -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<ZcRentCarRuleBattery> selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery);
List<Long> selectBatteryRuleIdsByCarRuleId(Long carRuleId);
/**
* 新增租车规则租电规则关联
*
@ -58,4 +60,7 @@ public interface ZcRentCarRuleBatteryMapper
* @return 结果
*/
public int deleteZcRentCarRuleBatteryByIds(String[] ids);
int batchInsert(@Param("list") List<ZcRentCarRuleBattery> ruleBatteryList);
}

View File

@ -27,6 +27,7 @@ public interface IZcRentCarRuleBatteryService
*/
public List<ZcRentCarRuleBattery> selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery);
List<Long> selectBatteryRuleIdsByCarRuleId(Long carRuleId);
/**
* 新增租车规则租电规则关联
*
@ -35,6 +36,8 @@ public interface IZcRentCarRuleBatteryService
*/
public int insertZcRentCarRuleBattery(ZcRentCarRuleBattery zcRentCarRuleBattery);
public int batchInsert(List<ZcRentCarRuleBattery> zcRentCarRuleBatteryList);
/**
* 修改租车规则租电规则关联
*

View File

@ -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<Long> 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<ZcRentCarRuleBattery> zcRentCarRuleBatteryList) {
return zcRentCarRuleBatteryMapper.batchInsert(zcRentCarRuleBatteryList);
}
/**
* 修改租车规则租电规则关联
*