|
|
@@ -1,10 +1,12 @@
|
|
|
package com.jzg.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.commons.constants.Constants;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
+import com.jzg.commons.core.page.ResultInfo;
|
|
|
import com.jzg.commons.entity.dto.JyxConfigAdd;
|
|
|
import com.jzg.commons.entity.dto.JyxConfigEnd;
|
|
|
import com.jzg.commons.entity.dto.JyxConfigParam;
|
|
|
@@ -53,9 +55,17 @@ public class JyxConfigServiceImpl extends ServiceImpl<JyxConfigMapper, JyxConfig
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加驾意险配置
|
|
|
+ *
|
|
|
+ * @param configAdd 要添加的驾意险信息
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/4/2 9:49
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult saveAll(JyxConfigAdd configAdd) {
|
|
|
+ public HttpResult<String> saveAll(JyxConfigAdd configAdd) {
|
|
|
+ log.info("添加驾意险信息:[{}]", JSONUtil.toJsonStr(configAdd));
|
|
|
try {
|
|
|
AssertionUtils.isFail(Optional.ofNullable(baseMapper.selectOne(new LambdaQueryWrapper<JyxConfig>().eq(JyxConfig::getProductCode, configAdd.getProductCode())
|
|
|
.eq(JyxConfig::getIsDelete, Constants.NOT_DELETED))).isPresent(), "产品编码重复");
|
|
|
@@ -83,6 +93,7 @@ public class JyxConfigServiceImpl extends ServiceImpl<JyxConfigMapper, JyxConfig
|
|
|
}
|
|
|
return HttpResult.ok("添加成功");
|
|
|
}catch (Exception e){
|
|
|
+ log.error("添加驾意险异常。configAdd=[{}]", JSONUtil.toJsonStr(configAdd), e);
|
|
|
return HttpResult.error("添加失败" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -154,12 +165,21 @@ public class JyxConfigServiceImpl extends ServiceImpl<JyxConfigMapper, JyxConfig
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询驾意险信息
|
|
|
+ *
|
|
|
+ * @param configParam 驾意险查询参数
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/4/2 9:54
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<JyxConfigVo> jyxList(JyxConfigParam configParam) {
|
|
|
+ public ResultInfo<List<JyxConfigVo>> jyxList(JyxConfigParam configParam) {
|
|
|
try {
|
|
|
List<JyxConfigVo> jyxConfigVos = Optional.ofNullable(jyxConfigMapper.jyxList(configParam)).orElse(Collections.emptyList());
|
|
|
if (StringUtils.isNotEmpty(configParam.getSeats()) || StringUtils.isNotEmpty(configParam.getParams())) {
|
|
|
- Set<String> ids = jyxConfigVos.stream().filter(v -> !ConstantsParent.PARENT_ID_ROOT.equals(v.getParentId())).map(JyxConfigVo::getParentId).collect(Collectors.toSet());
|
|
|
+ // modify by lipf 2026年4月2日10:10:00, 调换map和filter 来简化filter的写法
|
|
|
+ Set<String> ids = jyxConfigVos.stream().map(JyxConfigVo::getParentId)
|
|
|
+ .filter(parentId -> !ConstantsParent.PARENT_ID_ROOT.equals(parentId)).collect(Collectors.toSet());
|
|
|
if (!CollectionUtils.isEmpty(ids)){
|
|
|
List<JyxConfigVo> parentConfigs = jyxConfigMapper.selectParentIds(new ArrayList<>(ids));
|
|
|
jyxConfigVos.addAll(parentConfigs);
|
|
|
@@ -169,18 +189,19 @@ public class JyxConfigServiceImpl extends ServiceImpl<JyxConfigMapper, JyxConfig
|
|
|
));
|
|
|
}
|
|
|
if (jyxConfigVos.isEmpty()) {
|
|
|
- return Collections.emptyList();
|
|
|
+ log.info("根据查询条件[{}]查询出的驾意险信息为空", JSONUtil.toJsonStr(configParam));
|
|
|
+ return ResultInfo.resOk("查询出的驾意险数据为空", Collections.emptyList());
|
|
|
}
|
|
|
Map<String, List<JyxConfigVo>> childrenMap = jyxConfigVos.stream()
|
|
|
.filter(vo -> !ConstantsParent.PARENT_ID_ROOT.equals(vo.getParentId()))
|
|
|
.collect(Collectors.groupingBy(vo -> String.valueOf(vo.getParentId()), Collectors.mapping(Function.identity(), Collectors.toList())));
|
|
|
List<JyxConfigVo> configVos = jyxConfigVos.stream().filter(parentConfig -> ConstantsParent.PARENT_ID_ROOT.equals(parentConfig.getParentId())).collect(Collectors.toList());
|
|
|
configVos.forEach(parentConfig -> parentConfig.setChildren(childrenMap.getOrDefault(String.valueOf(parentConfig.getId()), Collections.emptyList())));
|
|
|
- return configVos;
|
|
|
+ return ResultInfo.resOk(null, configVos);
|
|
|
} catch (Exception e) {
|
|
|
// 记录日志或进行其他异常处理
|
|
|
- log.error("执行jyxList方法异常",e);
|
|
|
- return Collections.emptyList();
|
|
|
+ log.error("查询驾意险信息异常。 configParam=[{}]",JSONUtil.toJsonStr(configParam), e);
|
|
|
+ return ResultInfo.resError("查询驾意险异常,请联系管理员");
|
|
|
}
|
|
|
}
|
|
|
|