修改后保证各区域百分比和为100%

修改后保证各区域,各车系预测占比的百分比之和要等于100%。
区域分为北区,南区,中区
求支援

实现层代码
@Override
public void updateDtoById(TcWsCrFctRgnQuotaRatioDTO tcWsCrFctRgnQuotaRatioDTO) {
TcWsCrFctRgnQuotaRatioPO tcWsCrFctRgnQuotaRatioPO = tcWsCrFctRgnQuotaRatioMapper.selectById(tcWsCrFctRgnQuotaRatioDTO.getConfigId());
//TODO 修改需要根据页面元素,手动set需要修改的属性
tcWsCrFctRgnQuotaRatioPO.setRatio(tcWsCrFctRgnQuotaRatioDTO.getRatio());
int deleteCount = tcWsCrFctRgnQuotaRatioMapper.updateById(tcWsCrFctRgnQuotaRatioPO);
if (deleteCount <= 0) {
throw new ServiceBizException("修改失败,没有符合条件的数据");
}
}

实体类
private static final long serialVersionUID = 1L;

/**
 * 配置id
 */
private Long configId;

/**
 * 品牌代码
 */
@TableField("brand_code")
private String brandCode;

/**
 * 车系代码
 */
@TableField("series_code")
private String seriesCode;

/**
 * 区域代码
 */
@TableField("region_code")
private String regionCode;

/**
 * 百分比
 */
@TableField("ratio")
private String ratio;

img


这个接口只是根据配置更新传入的百分比,要保证各个百分比之和等于1,要么传入数量,后端计算,强一致保证百分比之和等于1,要么前端把比例算好,后端判断其和是否为一,批量更新。

这是一个联动关系,这个高了,其它的就需要降低,才能保证

img