|
|
@@ -1,9 +1,11 @@
|
|
|
package com.jzg.service.impl;
|
|
|
|
|
|
+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.PtlApiType;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
+import com.jzg.commons.entity.agreement.dto.PtlAttributionTemplateDto;
|
|
|
import com.jzg.commons.entity.agreement.po.PtlAgreementAttribution;
|
|
|
import com.jzg.commons.entity.agreement.po.PtlCrawlerApi;
|
|
|
import com.jzg.commons.entity.agreement.po.PtlInsAttributionTemplate;
|
|
|
@@ -21,15 +23,22 @@ import com.jzg.service.PtlAgreementService;
|
|
|
import com.jzg.service.PtlCrawlerApiService;
|
|
|
import com.jzg.service.PtlInsAttributionTemplateService;
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttributionTemplateMapper, PtlInsAttributionTemplate> implements PtlInsAttributionTemplateService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PtlInsAttributionTemplateServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
EsmInsCompanyService esmInsCompanyService;
|
|
|
|
|
|
@@ -64,12 +73,30 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
|
|
|
return baseMapper.selectOne(wrapper);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存 保险公司归属信息模版
|
|
|
+ *
|
|
|
+ * @param ptlInsAttributionTemplateSaveVo 保险公司归属信息模版, 内部包含多个对象
|
|
|
+ * @return HttpResult<Boolean>
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public boolean submit(List<PtlInsAttributionTemplateSaveVo> ptlInsAttributionTemplateSaveVo) {
|
|
|
+ public HttpResult<Boolean> submit(List<PtlInsAttributionTemplateSaveVo> ptlInsAttributionTemplateSaveVo) {
|
|
|
+ log.info("保存保险公司归属信息模板: ptlInsAttributionTemplateSaveVo=[{}]", JSONUtil.toJsonStr(ptlInsAttributionTemplateSaveVo));
|
|
|
// 一个保险公司,一种api方式只能配置一种
|
|
|
ptlInsAttributionTemplateSaveVo.forEach(this::validate);
|
|
|
-
|
|
|
+ List<PtlAttributionTemplateDto> fields = ptlInsAttributionTemplateSaveVo.get(0).getFields();
|
|
|
+ List<String> fieldList = fields.stream().map(PtlAttributionTemplateDto::getField).toList();
|
|
|
+ Set<String> duplicates = fieldList.stream()
|
|
|
+ .filter(n -> Collections.frequency(fieldList, n) > 1)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ if(!duplicates.isEmpty()) {
|
|
|
+ log.info("存在字段名称重复的设置。duplicates=[{}]", JSONUtil.toJsonStr(duplicates));
|
|
|
+ HttpResult<Boolean> res = new HttpResult<Boolean>();
|
|
|
+ res.setData(Boolean.FALSE);
|
|
|
+ res.setMsg("存在字段名称重复的设置. 重复字段是" + JSONUtil.toJsonStr(duplicates));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
ptlInsAttributionTemplateSaveVo.forEach(saveVo -> {
|
|
|
EsmInsCompany esmInsCompany = esmInsCompanyService.isExists(saveVo.getInsCompanyId());
|
|
|
PtlInsAttributionTemplate ptlInsAttributionTemplate = new PtlInsAttributionTemplate(saveVo, esmInsCompany.getCnName());
|
|
|
@@ -86,7 +113,7 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
|
|
|
AssertionUtils.isSucceed(b, "保险公司api请求插入失败");
|
|
|
}
|
|
|
});
|
|
|
- return true;
|
|
|
+ return HttpResult.ok("提交模板信息成功");
|
|
|
}
|
|
|
|
|
|
private void validate(PtlInsAttributionTemplateSaveVo ptlInsAttributionTemplateSaveVo) {
|