车型费用关联

This commit is contained in:
邱贞招 2024-11-29 11:10:20 +08:00
parent e4b648bec0
commit c6f3393772
11 changed files with 232 additions and 35 deletions

View File

@ -152,19 +152,6 @@ public class AppController extends BaseController
// return success(storeService.selectSmStoreList(storeQuery));
// }
/**
* 根据车型id获取详情
*/
@GetMapping("/getModelById")
public AjaxResult getModelById(Long modelId)
{
logger.info("根据车型id获取详情【modelId="+modelId+"");
if(modelId==null){
return error("车型id[modelId]未传");
}
return success(modelService.selectEModelByModelId(modelId));
}
// /**
// * 根据定位获取附近店铺列表
// */

View File

@ -610,7 +610,7 @@ public class AppVerifyController extends BaseController
}
return Boolean.TRUE;
});
if(!execute)throw new ServiceException("【改价】失败");
if(Boolean.FALSE.equals(execute))throw new ServiceException("【改价】失败");
return toAjax(1);
}
@ -957,6 +957,19 @@ public class AppVerifyController extends BaseController
return toAjax(1);
}
/**
* 根据车型id获取详情
*/
@GetMapping("/getModelById")
public AjaxResult getModelById(Long modelId)
{
logger.info("根据车型id获取详情【modelId={}】", modelId);
if(modelId==null){
return error("车型id[modelId]未传");
}
return success(modelService.selectEModelByModelId(modelId));
}
/**
* 查询车辆型号列表
*/
@ -973,7 +986,7 @@ public class AppVerifyController extends BaseController
*/
@Log(title = "车辆型号", businessType = BusinessType.INSERT)
@PostMapping("/model")
public AjaxResult addModel(@RequestBody EModel eModel)
public AjaxResult addModel(@RequestBody EModelQuery eModel)
{
logger.info("新增车辆型号:【{}】", JSON.toJSONString(eModel));
return toAjax(modelService.insertEModel(eModel));
@ -984,7 +997,7 @@ public class AppVerifyController extends BaseController
*/
@Log(title = "车辆型号", businessType = BusinessType.UPDATE)
@PutMapping("/model")
public AjaxResult editModel(@RequestBody EModel etModel)
public AjaxResult editModel(@RequestBody EModelQuery etModel)
{
logger.info("修改车辆型号:【{}】", JSON.toJSONString(etModel));
return toAjax(modelService.updateEModel(etModel));
@ -999,7 +1012,7 @@ public class AppVerifyController extends BaseController
{
logger.info("删除车辆型号:【{}】", JSON.toJSONString(modelIds));
for (Long modelId : modelIds){
EModel model = new EModel();
EModelQuery model = new EModelQuery();
model.setDelFlag("1");
model.setModelId(modelId);
int i = modelService.updateEModel(model);

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.model.EModel;
import com.ruoyi.system.domain.model.EModelQuery;
import com.ruoyi.system.domain.model.EModelVO;
import com.ruoyi.system.service.IEModelService;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,7 +71,7 @@ public class EModelController extends BaseController
@PreAuthorize("@ss.hasPermi('system:model:add')")
@Log(title = "车辆型号", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EModel eModel)
public AjaxResult add(@RequestBody EModelQuery eModel)
{
return toAjax(eModelService.insertEModel(eModel));
}
@ -81,7 +82,7 @@ public class EModelController extends BaseController
@PreAuthorize("@ss.hasPermi('system:model:edit')")
@Log(title = "车辆型号", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EModel etModel)
public AjaxResult edit(@RequestBody EModelQuery etModel)
{
return toAjax(eModelService.updateEModel(etModel));
}

View File

@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
port: 8100
servlet:
# 应用的访问路径
context-path: /

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 车辆型号对象 et_model
@ -59,5 +60,7 @@ public class EModel extends BaseEntity
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 商户id */
private Long merchantId;
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.system.domain.modelRule;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 车型和收费方式关联对象 e_model_rule
*
* @author qzz
* @date 2024-11-29
*/
public class EModelRule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 车型id */
private Long modelId;
/** 收费模版id */
private Long ruleId;
public void setModelId(Long modelId)
{
this.modelId = modelId;
}
public Long getModelId()
{
return modelId;
}
public void setRuleId(Long ruleId)
{
this.ruleId = ruleId;
}
public Long getRuleId()
{
return ruleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("modelId", getModelId())
.append("ruleId", getRuleId())
.toString();
}
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.modelRule.EModelRule;
import java.util.List;
/**
* 车型和收费方式关联Mapper接口
*
* @author qzz
* @date 2024-11-29
*/
public interface EModelRuleMapper
{
/**
* 查询车型和收费方式关联
*
* @param modelId 车型和收费方式关联主键
* @return 车型和收费方式关联
*/
public EModelRule selectEModelRuleByModelId(Long modelId);
/**
* 查询车型和收费方式关联列表
*
* @param eModelRule 车型和收费方式关联
* @return 车型和收费方式关联集合
*/
public List<EModelRule> selectEModelRuleList(EModelRule eModelRule);
/**
* 新增车型和收费方式关联
*
* @param eModelRule 车型和收费方式关联
* @return 结果
*/
public int insertEModelRule(EModelRule eModelRule);
/**
* 修改车型和收费方式关联
*
* @param eModelRule 车型和收费方式关联
* @return 结果
*/
public int updateEModelRule(EModelRule eModelRule);
/**
* 删除车型和收费方式关联
*
* @param modelId 车型和收费方式关联主键
* @return 结果
*/
public int deleteEModelRuleByModelId(Long modelId);
/**
* 批量删除车型和收费方式关联
*
* @param modelIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteEModelRuleByModelIds(Long[] modelIds);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.service;
import com.ruoyi.system.domain.EFunction;
import com.ruoyi.system.domain.model.EModel;
import com.ruoyi.system.domain.model.EModelQuery;
import com.ruoyi.system.domain.model.EModelVO;
import java.util.List;
@ -36,7 +37,7 @@ public interface IEModelService
* @param etModel 车辆型号
* @return 结果
*/
public int insertEModel(EModel etModel);
public int insertEModel(EModelQuery etModel);
/**
* 修改车辆型号
@ -44,7 +45,7 @@ public interface IEModelService
* @param etModel 车辆型号
* @return 结果
*/
public int updateEModel(EModel etModel);
public int updateEModel(EModelQuery etModel);
/**
* 批量删除车辆型号

View File

@ -2,15 +2,17 @@ package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.system.domain.EFunction;
import com.ruoyi.system.domain.device.EDevice;
import com.ruoyi.system.domain.model.EModel;
import com.ruoyi.system.domain.model.EModelQuery;
import com.ruoyi.system.domain.model.EModelVO;
import com.ruoyi.system.domain.modelRule.EModelRule;
import com.ruoyi.system.domain.rule.EFeeRule;
import com.ruoyi.system.mapper.EModelMapper;
import com.ruoyi.system.service.IEBrandService;
import com.ruoyi.system.service.IEDeviceService;
import com.ruoyi.system.service.IEModelService;
import com.ruoyi.system.service.IEFunctionService;
import com.ruoyi.system.mapper.EModelRuleMapper;
import com.ruoyi.system.service.*;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,6 +44,12 @@ public class EModelServiceImpl implements IEModelService
@Autowired
private IEBrandService brandService;
@Autowired
private IEFeeRuleService feeRuleService;
@Autowired
private EModelRuleMapper eModelRuleMapper;
/**
* 查询车辆型号
@ -53,10 +61,9 @@ public class EModelServiceImpl implements IEModelService
public EModelVO selectEModelByModelId(Long modelId)
{
EModelVO etModel = eModelMapper.selectEModelByModelId(modelId);
// if(ObjectUtil.isNotNull(etModel)){
// Integer allNum = eDeviceService.selectCountByModelId(modelId);
// etModel.setDeviceNum(allNum);
// }
if(etModel != null){
etModel.setFeeRulesIds(feeRuleService.selectRlFeeRuleLongListByModelId(etModel.getModelId()));
}
return etModel;
}
@ -82,16 +89,29 @@ public class EModelServiceImpl implements IEModelService
@SneakyThrows
@Override
@Transactional
public int insertEModel(EModel etModel)
public int insertEModel(EModelQuery etModel)
{
etModel.setCreateTime(DateUtils.getNowDate());
if(etModel.getBrandId() != null){
etModel.setBrandName(brandService.selectEBrandByBrandId(etModel.getBrandId()).getName());
}
int i = eModelMapper.insertEModel(etModel);
saveModelRule(etModel);
return i;
}
private void saveModelRule(EModelQuery etModel) {
if(etModel.getFeeRulesIds() != null){
Long[] feeRulesIds = etModel.getFeeRulesIds();
for (Long feeRuleId:feeRulesIds){
EModelRule eModelRule = new EModelRule();
eModelRule.setModelId(etModel.getModelId());
eModelRule.setRuleId(feeRuleId);
int i1 = eModelRuleMapper.insertEModelRule(eModelRule);
}
}
}
/**
* 修改车辆型号
*
@ -101,14 +121,17 @@ public class EModelServiceImpl implements IEModelService
@SneakyThrows
@Override
@Transactional
public int updateEModel(EModel etModel)
public int updateEModel(EModelQuery etModel)
{
etModel.setUpdateTime(DateUtils.getNowDate());
if(etModel.getBrandId() != null){
etModel.setBrandName(brandService.selectEBrandByBrandId(etModel.getBrandId()).getName());
}
int i = eModelMapper.updateEModel(etModel);
return i;
int i = eModelRuleMapper.deleteEModelRuleByModelId(etModel.getModelId());
if(i>0){
saveModelRule(etModel);
}
return eModelMapper.updateEModel(etModel);
}
/**

View File

@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRlFeeRuleLongListByModelId" resultType="java.lang.Long">
select r.rule_id from e_fee_rule r
left join e_fee_rule mr on mr.rule_id = r.rule_id
left join e_model_rule mr on mr.rule_id = r.rule_id
where mr.model_id = #{modelId}
</select>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EModelRuleMapper">
<resultMap type="EModelRule" id="EModelRuleResult">
<result property="modelId" column="model_id" />
<result property="ruleId" column="rule_id" />
</resultMap>
<sql id="selectEModelRuleVo">
select model_id, rule_id from e_model_rule
</sql>
<select id="selectEModelRuleList" parameterType="EModelRule" resultMap="EModelRuleResult">
<include refid="selectEModelRuleVo"/>
<where>
</where>
</select>
<select id="selectEModelRuleByModelId" parameterType="Long" resultMap="EModelRuleResult">
<include refid="selectEModelRuleVo"/>
where model_id = #{modelId}
</select>
<insert id="insertEModelRule" parameterType="EModelRule">
insert into e_model_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelId != null">model_id,</if>
<if test="ruleId != null">rule_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelId != null">#{modelId},</if>
<if test="ruleId != null">#{ruleId},</if>
</trim>
</insert>
<update id="updateEModelRule" parameterType="EModelRule">
update e_model_rule
<trim prefix="SET" suffixOverrides=",">
<if test="ruleId != null">rule_id = #{ruleId},</if>
</trim>
where model_id = #{modelId}
</update>
<delete id="deleteEModelRuleByModelId" parameterType="Long">
delete from e_model_rule where model_id = #{modelId}
</delete>
<delete id="deleteEModelRuleByModelIds" parameterType="String">
delete from e_model_rule where model_id in
<foreach item="modelId" collection="array" open="(" separator="," close=")">
#{modelId}
</foreach>
</delete>
</mapper>