Commit 1b0f26a8 by ThomasAdv

oneId生成逻辑

1 parent e3f6f9b6
Showing 24 changed files with 722 additions and 8 deletions
...@@ -36,6 +36,12 @@ public class CarMaintenanceInsurance implements Serializable { ...@@ -36,6 +36,12 @@ public class CarMaintenanceInsurance implements Serializable {
private String carId; private String carId;
/** /**
* 维保标签
*/
@Column(name = "car_maintenance_insurance_tag")
private String carMaintenanceInsuranceTag;
/**
* 商业险订单号 * 商业险订单号
*/ */
@Column(name = "car_ins_no") @Column(name = "car_ins_no")
......
...@@ -65,6 +65,24 @@ public class CustomerSopJourney implements Serializable { ...@@ -65,6 +65,24 @@ public class CustomerSopJourney implements Serializable {
private String sopFollowUpPerson; private String sopFollowUpPerson;
/** /**
* 跟进人手机号
*/
@Column(name = "sop_follow_up_person_phone")
private String sopFollowUpPersonPhone;
/**
* 跟进人AI营销话术
*/
@Column(name = "sop_follow_up_person_aiSpeech")
private String sopFollowUpPersonAiSpeech;
/**
* 跟进人短信
*/
@Column(name = "sop_follow_up_person_sms")
private String sopFollowUpPersonSms;
/**
* 来源 * 来源
*/ */
@Column(name = "add_way") @Column(name = "add_way")
......
package cn.com.glsx.cdp.modules.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
@Table(name = "cdp_oneid_field_config")
public class OneIdFieldConfig implements Serializable {
private static final long serialVersionUID = 9187589612278038952L;
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 组织ID
*/
@Column(name = "org_id")
private String orgId;
/**
* 业务类型1.客户 2.车辆
*/
@Column(name = "business_type")
private Byte businessType;
/**
* 字段
*/
@Column(name = "field_name")
private String fieldName;
/**
* 字段描述
*/
@Column(name = "field_describe")
private String fieldDescribe;
/**
* 优先级
*/
private Byte priority;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
/**
* 是否删除:0=正常,-1=删除
*/
@Column(name = "del_flag")
private Integer delFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.cdp.modules.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
@Table(name = "cdp_oneid_mapping")
public class OneIdMapping implements Serializable {
private static final long serialVersionUID = 911042986292649756L;
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 组织ID
*/
@Column(name = "org_id")
private String orgId;
/**
* 业务类型1.客户 2.车辆
*/
@Column(name = "business_type")
private Byte businessType;
/**
* 字段
*/
@Column(name = "field_name")
private String fieldName;
/**
* 字段值
*/
@Column(name = "field_value")
private String fieldValue;
/**
* one_id
*/
@Column(name = "one_id")
private String oneId;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
/**
* 是否删除:0=正常,-1=删除
*/
@Column(name = "del_flag")
private Integer delFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.cdp.modules.enums;
public enum CustomerEventTypeEnum {
SENT_SMS("SENT_SMS", "已发送短信"),
READ_URL("READ_URL","已查看链接"),
SENT_1V1_GROUP_MSG("SENT_1V1_GROUP_MSG","已1v1群发"),
SENT_AI_CALL("SENT_AI_CALL", "已发送ai外呼"),
RECALL_AI_CALL("RECALL_AI_CALL", "ai外呼回调"),
SHARED_WECHAT_MOMENT("SHARED_WECHAT_MOMENT","已分享朋友圈"),
ORDERED("ORDERED","已下单"),
ORDER_REFUNDED("ORDER_REFUNDED", "订单退款")
;
private final String value;
private final String displayText;
CustomerEventTypeEnum(String value, String displayText){
this.value = value;
this.displayText = displayText;
}
public String getValue() {
return value;
}
public String getDisplayText() {
return displayText;
}
public static CustomerEventTypeEnum getByValue(String value){
if (value != null) {
for (CustomerEventTypeEnum temp : CustomerEventTypeEnum.values()) {
if (temp.getValue().equals(value)) {
return temp;
}
}
}
return null;
}
}
...@@ -53,4 +53,14 @@ public class CustomerSopJourneyDTO implements Serializable { ...@@ -53,4 +53,14 @@ public class CustomerSopJourneyDTO implements Serializable {
@Schema(description = "跟进人") @Schema(description = "跟进人")
private String sopFollowUpPerson; private String sopFollowUpPerson;
@Schema(description = "跟进人手机号")
private String sopFollowUpPersonPhone;
@Schema(description = "跟进人AI营销话术")
private String sopFollowUpPersonAiSpeech;
@Schema(description = "跟进人短信")
private String sopFollowUpPersonSms;
} }
...@@ -12,5 +12,6 @@ import com.glsx.plat.core.constant.BasicConstants; ...@@ -12,5 +12,6 @@ import com.glsx.plat.core.constant.BasicConstants;
public final class Constants extends BasicConstants { public final class Constants extends BasicConstants {
public final static String SERVER_NAME = "glsx_rest_admin"; public final static String SERVER_NAME = "glsx_rest_admin";
public final static String DEFAULT_UPDATED_BY = "system";
} }
...@@ -4,5 +4,4 @@ public class ModelFieldConstants { ...@@ -4,5 +4,4 @@ public class ModelFieldConstants {
public final static String ORGID = "org_id"; public final static String ORGID = "org_id";
public final static String ADD_WAY = "add_way"; public final static String ADD_WAY = "add_way";
public final static String EX_JSON = "ex_json"; public final static String EX_JSON = "ex_json";
} }
package cn.com.glsx.cdp.modules.converter;
import cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO;
import cn.com.glsx.cdp.modules.model.OneIdMappingDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface OneIdMappingDTOConvert {
OneIdMappingDTOConvert INSTANCE = Mappers.getMapper(OneIdMappingDTOConvert.class);
@Mappings({
@Mapping(source = "oneIdFieldConfigDTO.*", target = "."),
@Mapping(source = "oneId", target = "oneId"),
@Mapping(source = "updatedBy", target = "updatedBy"),
@Mapping(source = "updatedBy", target = "createdBy")
})
OneIdMappingDTO fromOneIdFieldConfig(String oneId, OneIdFieldConfigDTO oneIdFieldConfigDTO, String updatedBy);
}
package cn.com.glsx.cdp.modules.enums;
public enum OneIdBusinessTypeEnum {
CUSTOMER((byte)1, "客户"),
CAR((byte)2,"车");
private final Byte value;
private final String displayText;
OneIdBusinessTypeEnum(Byte value, String displayText){
this.value = value;
this.displayText = displayText;
}
public Byte getValue() {
return value;
}
public String getDisplayText() {
return displayText;
}
public static OneIdBusinessTypeEnum getByValue(Byte value){
if (value != null) {
for (OneIdBusinessTypeEnum temp : OneIdBusinessTypeEnum.values()) {
if (temp.getValue().equals(value)) {
return temp;
}
}
}
return null;
}
}
...@@ -2,6 +2,8 @@ package cn.com.glsx.cdp.modules.mapper; ...@@ -2,6 +2,8 @@ package cn.com.glsx.cdp.modules.mapper;
import cn.com.glsx.cdp.modules.entity.CarMaintenanceInsurance; import cn.com.glsx.cdp.modules.entity.CarMaintenanceInsurance;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CarMaintenanceInsuranceMapper extends CommonBaseMapper<CarMaintenanceInsurance> { public interface CarMaintenanceInsuranceMapper extends CommonBaseMapper<CarMaintenanceInsurance> {
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.cdp.modules.mapper;
import cn.com.glsx.cdp.modules.entity.OneIdFieldConfig;
import cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface OneIdFieldConfigMapper extends CommonBaseMapper<OneIdFieldConfig> {
List<OneIdFieldConfigDTO> list(OneIdFieldConfigDTO oneIdFieldConfigDTO);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.cdp.modules.mapper;
import cn.com.glsx.cdp.modules.entity.OneIdMapping;
import cn.com.glsx.cdp.modules.model.OneIdMappingDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface OneIdMappingMapper extends CommonBaseMapper<OneIdMapping> {
List<OneIdMappingDTO> list(OneIdMappingDTO oneIdMappingDTO);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.cdp.modules.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
public class FindOrCreateOneIdParam implements Serializable {
private static final long serialVersionUID = -2777667996290039105L;
// 组织ID
private String orgId;
// 业务类型1.客户 2.车辆
private Byte businessType;
// oneId字段json
private String oneIdFieldJson;
}
package cn.com.glsx.cdp.modules.model;
import cn.com.glsx.cdp.modules.entity.OneIdFieldConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@ToString(callSuper = true)
@Data
public class OneIdFieldConfigDTO extends OneIdFieldConfig {
private static final long serialVersionUID = 3839452358183537235L;
private String fieldValue;
}
package cn.com.glsx.cdp.modules.model;
import cn.com.glsx.cdp.modules.entity.OneIdMapping;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@ToString(callSuper = true)
@Data
public class OneIdMappingDTO extends OneIdMapping {
private static final long serialVersionUID = -7012176705275858210L;
private List<String> fieldNames;
private List<String> oneIds;
}
...@@ -4,9 +4,11 @@ import cn.com.glsx.cdp.common.constant.ModelFieldConstants; ...@@ -4,9 +4,11 @@ import cn.com.glsx.cdp.common.constant.ModelFieldConstants;
import cn.com.glsx.cdp.config.RabbitMQConfig; import cn.com.glsx.cdp.config.RabbitMQConfig;
import cn.com.glsx.cdp.modules.enums.ModelFieldUnionRuleEnum; import cn.com.glsx.cdp.modules.enums.ModelFieldUnionRuleEnum;
import cn.com.glsx.cdp.modules.enums.OneIdBelongEnum; import cn.com.glsx.cdp.modules.enums.OneIdBelongEnum;
import cn.com.glsx.cdp.modules.model.FindOrCreateOneIdParam;
import cn.com.glsx.cdp.modules.model.ModelDTO; import cn.com.glsx.cdp.modules.model.ModelDTO;
import cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO; import cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO;
import cn.com.glsx.cdp.modules.service.ModelService; import cn.com.glsx.cdp.modules.service.ModelService;
import cn.com.glsx.cdp.modules.service.OneIdService;
import cn.com.glsx.cdp.modules.util.DateUtil; import cn.com.glsx.cdp.modules.util.DateUtil;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -40,6 +42,8 @@ import java.util.stream.Collectors; ...@@ -40,6 +42,8 @@ import java.util.stream.Collectors;
public class DataReportRabbitMQConsumer { public class DataReportRabbitMQConsumer {
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
@Autowired
private OneIdService oneIdService;
/** /**
* 处理数据上报 * 处理数据上报
...@@ -57,7 +61,8 @@ public class DataReportRabbitMQConsumer { ...@@ -57,7 +61,8 @@ public class DataReportRabbitMQConsumer {
log.info("data report Data: {}", jsonDataStr); log.info("data report Data: {}", jsonDataStr);
if (StringUtils.isNotBlank(jsonDataStr)) { if (StringUtils.isNotBlank(jsonDataStr)) {
try { try {
JSONObject jsonData = JSONArray.parseObject(jsonDataStr); List<JSONObject> jsonDatas = JSONArray.parseArray(jsonDataStr, JSONObject.class);
for (JSONObject jsonData : jsonDatas) {
Integer orgId = jsonData.getInteger(ModelFieldConstants.ORGID); Integer orgId = jsonData.getInteger(ModelFieldConstants.ORGID);
Integer addWay = jsonData.getInteger(ModelFieldConstants.ADD_WAY); Integer addWay = jsonData.getInteger(ModelFieldConstants.ADD_WAY);
if (orgId != null && addWay != null) { if (orgId != null && addWay != null) {
...@@ -68,6 +73,8 @@ public class DataReportRabbitMQConsumer { ...@@ -68,6 +73,8 @@ public class DataReportRabbitMQConsumer {
} else { } else {
log.error("data report consume error,orgId or addWay is null"); log.error("data report consume error,orgId or addWay is null");
} }
}
} catch (Exception e) { } catch (Exception e) {
log.error("data report consume error,time:{},e:{}", LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME), e); log.error("data report consume error,time:{},e:{}", LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME), e);
} }
...@@ -448,12 +455,17 @@ public class DataReportRabbitMQConsumer { ...@@ -448,12 +455,17 @@ public class DataReportRabbitMQConsumer {
if (oneIdBelongEnum == null) { if (oneIdBelongEnum == null) {
throw new RpcServiceException("none or undefined oneIdBelong:"+oneIdBelong); throw new RpcServiceException("none or undefined oneIdBelong:"+oneIdBelong);
} }
List<ModelFieldMappingDTO> oneIdFields = oneIdBelongGroupModelMap.get(oneIdBelong).getModelFieldMappings() Map<String, Object> oneIdFieldMap = oneIdBelongGroupModelMap.get(oneIdBelong).getModelFieldMappings().stream()
.stream().filter(o -> o.getOneidFlag() != null && o.getOneidFlag()).collect(Collectors.toList()); .filter(o -> o.getOneidFlag() != null && o.getOneidFlag())
//TODO oneId生成 .collect(
oneIdBelongEnumStringMap.put(oneIdBelongEnum, UUID.randomUUID().toString().replace("-", "")); Collectors.toMap(ModelFieldMappingDTO::getFieldName, o -> o.getFieldValue(), (o1, o2) -> o2)
);
FindOrCreateOneIdParam param = FindOrCreateOneIdParam.builder().orgId(jsonData.getString(ModelFieldConstants.ORGID)).businessType(oneIdBelong).oneIdFieldJson(JSONObject.toJSONString(oneIdFieldMap)).build();
String oneId = oneIdService.findOrCreateOneId(param);
oneIdBelongEnumStringMap.put(oneIdBelongEnum, oneId);
} }
} }
return oneIdBelongEnumStringMap;
} }
return null; return null;
} }
......
package cn.com.glsx.cdp.modules.service;
import cn.com.glsx.cdp.modules.mapper.OneIdFieldConfigMapper;
import cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class OneIdFieldConfigService {
@Autowired
private OneIdFieldConfigMapper oneIdFieldConfigMapper;
public List<OneIdFieldConfigDTO> list(OneIdFieldConfigDTO oneIdFieldConfigDTO){
try{
return oneIdFieldConfigMapper.list(oneIdFieldConfigDTO);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
}
package cn.com.glsx.cdp.modules.service;
import cn.com.glsx.cdp.common.constant.Constants;
import cn.com.glsx.cdp.modules.converter.OneIdMappingDTOConvert;
import cn.com.glsx.cdp.modules.mapper.OneIdMappingMapper;
import cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO;
import cn.com.glsx.cdp.modules.model.OneIdMappingDTO;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class OneIdMappingService {
@Autowired
private OneIdMappingMapper oneIdMappingMapper;
public List<OneIdMappingDTO> list(OneIdMappingDTO oneIdMappingDTO){
try{
return oneIdMappingMapper.list(oneIdMappingDTO);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
public OneIdMappingDTO getOneIdMapping(String orgId, Byte businessType, String fieldName){
OneIdMappingDTO oneIdMappingDTO = OneIdMappingDTO.builder().orgId(orgId)
.businessType(businessType)
.fieldName(fieldName).build();
List<OneIdMappingDTO> list = list(oneIdMappingDTO);
if (CollectionUtils.isNotEmpty(list)) {
return list.get(0);
}
return null;
}
public void saveOneIdMapping(String oneId, OneIdFieldConfigDTO oneIdFieldConfigDTO){
RpcAssert.assertNotNull(oneIdFieldConfigDTO, DefaultErrorEnum.DATA_NULL,"oneIdFieldConfigDTO not be null");
RpcAssert.assertNotNull(oneIdFieldConfigDTO.getOrgId(), DefaultErrorEnum.DATA_NULL,"oneIdFieldConfigDTO.getOrgId() not be null");
RpcAssert.assertNotNull(oneIdFieldConfigDTO.getBusinessType(), DefaultErrorEnum.DATA_NULL,"oneIdFieldConfigDTO.getBusinessType() not be null");
RpcAssert.assertNotEmpty(oneIdFieldConfigDTO.getFieldName(), DefaultErrorEnum.DATA_NULL,"oneIdFieldConfigDTO.getFieldName() not be empty");
RpcAssert.assertNotEmpty(oneIdFieldConfigDTO.getFieldValue(), DefaultErrorEnum.DATA_NULL,"oneIdFieldConfigDTO.getFieldValue() not be empty");
RpcAssert.assertNotEmpty(oneId, DefaultErrorEnum.DATA_NULL,"oneId not be empty");
OneIdMappingDTO record = OneIdMappingDTOConvert.INSTANCE.fromOneIdFieldConfig(oneId, oneIdFieldConfigDTO, Constants.DEFAULT_UPDATED_BY);
try{
oneIdMappingMapper.insertSelective(record);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
}
package cn.com.glsx.cdp.modules.service;
import cn.com.glsx.cdp.modules.model.FindOrCreateOneIdParam;
import cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO;
import cn.com.glsx.cdp.modules.model.OneIdMappingDTO;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class OneIdService {
@Autowired
private OneIdMappingService oneIdMappingService;
@Autowired
private OneIdFieldConfigService oneIdFieldConfigService;
/**
* 查找或创建oneId
*
* @param param
* @return java.lang.String
* @author caiym
* @date 2023年09月21日 16:07:51
*/
public String findOrCreateOneId(FindOrCreateOneIdParam param){
RpcAssert.assertNotNull(param, DefaultErrorEnum.DATA_NULL,"param not be null");
RpcAssert.assertNotNull(param.getOrgId(), DefaultErrorEnum.DATA_NULL,"param.getOrgId() not be null");
RpcAssert.assertNotNull(param.getBusinessType(), DefaultErrorEnum.DATA_NULL,"param.getBusinessType() not be null");
RpcAssert.assertNotEmpty(param.getOneIdFieldJson(), DefaultErrorEnum.DATA_NULL,"param.getOneIdFieldJson() not be empty");
List<OneIdFieldConfigDTO> readyMatchOneIdFieldConfigs = getReadyMatchOneIdFieldConfigs(param);
//TODO 分布式锁
String finalOneId = null;
if (CollectionUtils.isNotEmpty(readyMatchOneIdFieldConfigs)) {
for (OneIdFieldConfigDTO readyMatchOneIdFieldConfig : readyMatchOneIdFieldConfigs) {
finalOneId = findOrCreateOneId(finalOneId, readyMatchOneIdFieldConfig);
}
}else{
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "none match oneId field config, param: " + JSONObject.toJSONString(param));
}
return finalOneId;
}
/**
* 查找或创建oneId
*
* @param finalOneId
* @param readyMatchOneIdFieldConfig
* @return java.lang.String
* @author caiym
* @date 2023年09月21日 16:53:44
*/
public String findOrCreateOneId(String finalOneId, OneIdFieldConfigDTO readyMatchOneIdFieldConfig){
OneIdMappingDTO oneIdMapping = oneIdMappingService.getOneIdMapping(readyMatchOneIdFieldConfig.getOrgId(),
readyMatchOneIdFieldConfig.getBusinessType(), readyMatchOneIdFieldConfig.getFieldName());
if (oneIdMapping == null) {
if (StringUtils.isBlank(finalOneId)) {
//TODO 雪花算法
finalOneId = UUID.randomUUID().toString().replace("-", "");
}
oneIdMappingService.saveOneIdMapping(finalOneId, readyMatchOneIdFieldConfig);
}else if (StringUtils.isBlank(finalOneId)) {
finalOneId = oneIdMapping.getOneId();
}
return finalOneId;
}
/**
* 获取准备匹配的oneId字段配置
*
* @param param
* @return java.util.List<cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO>
* @author caiym
* @date 2023年09月21日 15:27:53
*/
private List<OneIdFieldConfigDTO> getReadyMatchOneIdFieldConfigs(FindOrCreateOneIdParam param) {
JSONObject oneIdField = JSONObject.parseObject(param.getOneIdFieldJson());
OneIdFieldConfigDTO oneIdFieldConfigDTO = OneIdFieldConfigDTO.builder().orgId(param.getOrgId()).businessType(param.getBusinessType()).build();
List<OneIdFieldConfigDTO> oneIdFieldConfigDTOS = oneIdFieldConfigService.list(oneIdFieldConfigDTO);
if (CollectionUtils.isEmpty(oneIdFieldConfigDTOS)) {
throw new RpcServiceException(DefaultErrorEnum.DATA_NULL, "have not config org oneId field, orgId: " + param.getOrgId() + ", businessType: " + param.getBusinessType());
}
oneIdFieldConfigDTOS = oneIdFieldConfigDTOS.stream()
.filter(o -> oneIdField.containsKey(o.getFieldName()))
.map(o -> {
o.setFieldValue(oneIdField.getString(o.getFieldName()));
return o;
})
.sorted(Comparator.comparing(OneIdFieldConfigDTO::getPriority))
.collect(Collectors.toList());
return oneIdFieldConfigDTOS;
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" /> <result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="car_id" jdbcType="VARCHAR" property="carId" /> <result column="car_id" jdbcType="VARCHAR" property="carId" />
<result column="car_maintenance_insurance_tag" jdbcType="VARCHAR" property="carMaintenanceInsuranceTag" />
<result column="car_ins_no" jdbcType="VARCHAR" property="carInsNo" /> <result column="car_ins_no" jdbcType="VARCHAR" property="carInsNo" />
<result column="car_cpy_ins_no" jdbcType="VARCHAR" property="carCpyInsNo" /> <result column="car_cpy_ins_no" jdbcType="VARCHAR" property="carCpyInsNo" />
<result column="car_cpy_ins_start_time" jdbcType="TIMESTAMP" property="carCpyInsStartTime" /> <result column="car_cpy_ins_start_time" jdbcType="TIMESTAMP" property="carCpyInsStartTime" />
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, org_id, car_id, car_ins_no, car_cpy_ins_no, car_cpy_ins_start_time, car_cpy_ins_end_time, id, org_id, car_id, car_maintenance_insurance_tag, car_ins_no, car_cpy_ins_no, car_cpy_ins_start_time, car_cpy_ins_end_time,
car_first_maintenance_date, car_last_maintenance_time, car_previous_maintenance_date, car_first_maintenance_date, car_last_maintenance_time, car_previous_maintenance_date,
car_maintenance_notification_date, car_maintenance_hour, car_maintenance_amount, car_maintenance_notification_date, car_maintenance_hour, car_maintenance_amount,
car_maintenance_time, car_maintenance_frequency, car_free_maintenance_time, car_average_maintenance_day, car_maintenance_time, car_maintenance_frequency, car_free_maintenance_time, car_average_maintenance_day,
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
<result column="sop_journey_enter_time" jdbcType="TIMESTAMP" property="sopJourneyEnterTime" /> <result column="sop_journey_enter_time" jdbcType="TIMESTAMP" property="sopJourneyEnterTime" />
<result column="sop_journey_stage_enter_time" jdbcType="TIMESTAMP" property="sopJourneyStageEnterTime" /> <result column="sop_journey_stage_enter_time" jdbcType="TIMESTAMP" property="sopJourneyStageEnterTime" />
<result column="sop_follow_up_person" jdbcType="VARCHAR" property="sopFollowUpPerson" /> <result column="sop_follow_up_person" jdbcType="VARCHAR" property="sopFollowUpPerson" />
<result column="sop_follow_up_person_phone" jdbcType="VARCHAR" property="sopFollowUpPersonPhone" />
<result column="sop_follow_up_person_aiSpeech" jdbcType="VARCHAR" property="sopFollowUpPersonAiSpeech" />
<result column="sop_follow_up_person_sms" jdbcType="VARCHAR" property="sopFollowUpPersonSms" />
<result column="ex_json" jdbcType="LONGVARCHAR" property="exJson" /> <result column="ex_json" jdbcType="LONGVARCHAR" property="exJson" />
<result column="add_way" jdbcType="INTEGER" property="addWay" /> <result column="add_way" jdbcType="INTEGER" property="addWay" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" /> <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
...@@ -26,7 +29,8 @@ ...@@ -26,7 +29,8 @@
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, org_id, one_id, sop_journey_id, sop_journey_stage, sop_journey_enter_time, sop_journey_stage_enter_time, id, org_id, one_id, sop_journey_id, sop_journey_stage, sop_journey_enter_time, sop_journey_stage_enter_time,
sop_follow_up_person, add_way, created_by, created_time, updated_by, updated_time, sop_follow_up_person, sop_follow_up_person_phone, sop_follow_up_person_aiSpeech,
sop_follow_up_person_sms, add_way, created_by, created_time, updated_by, updated_time,
del_flag del_flag
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
......
<?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="cn.com.glsx.cdp.modules.mapper.OneIdFieldConfigMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.cdp.modules.entity.OneIdFieldConfig">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="business_type" jdbcType="TINYINT" property="businessType" />
<result column="field_name" jdbcType="VARCHAR" property="fieldName" />
<result column="field_describe" jdbcType="VARCHAR" property="fieldDescribe" />
<result column="priority" jdbcType="TINYINT" property="priority" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, org_id, business_type, field_name, field_describe, priority, created_by, created_time,
updated_by, updated_time, del_flag
</sql>
<select id="list" resultType="cn.com.glsx.cdp.modules.model.OneIdFieldConfigDTO">
select <include refid="Base_Column_List"></include>
from cdp_oneid_field_config
<where>
del_flag = 0
<if test="orgId != null">
and org_id = #{orgId}
</if>
<if test="businessType != null">
and business_type = #{businessType}
</if>
</where>
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?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="cn.com.glsx.cdp.modules.mapper.OneIdMappingMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.cdp.modules.entity.OneIdMapping">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="business_type" jdbcType="TINYINT" property="businessType" />
<result column="field_name" jdbcType="VARCHAR" property="fieldName" />
<result column="field_value" jdbcType="VARCHAR" property="fieldValue" />
<result column="one_id" jdbcType="VARCHAR" property="oneId" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, org_id, business_type, field_name, field_value, one_id, created_by, created_time,
updated_by, updated_time, del_flag
</sql>
<select id="list" resultType="cn.com.glsx.cdp.modules.model.OneIdMappingDTO">
select
<include refid="Base_Column_List" />
from cdp_oneid_mapping
<where>
del_flag = 0
<if test="orgId != null">
and org_id = #{orgId}
</if>
<if test="businessType != null">
and business_type = #{businessType}
</if>
<if test="fieldName != null">
and field_name = #{fieldName}
</if>
<if test="oneId != null">
and one_id = #{oneId}
</if>
<if test="fieldNames != null and fieldNames.size()>0">
and field_name in
<foreach collection="fieldNames" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="oneIds != null and oneIds.size()>0">
and one_id in
<foreach collection="oneIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!