package com.changhong.epc.tenant.service.norm.impl;
|
|
import com.changhong.epc.bean.tenant.master.MasterDefine;
|
import com.changhong.epc.bean.tenant.master.extend.MasterDefinesExtend;
|
import com.changhong.epc.tenant.mapper.tenant.norm.MasterDefineMapper;
|
import com.changhong.epc.tenant.service.norm.MasterValTool;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import lombok.extern.slf4j.Slf4j;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Objects;
|
|
@Slf4j
|
public abstract class SimplAbstractMasterTools<P, R> implements MasterValTool<P, R> {
|
|
@Resource
|
private MasterDefineMapper masterDefineMapper;
|
|
@Override
|
public R getVal(String code, P p) {
|
MasterDefinesExtend masterDefineExtend = selectDefAndMapOne(code);
|
if(masterDefineExtend == null){
|
return null;
|
}
|
// 映射二维主数据
|
if(ObjectUtil.notEmpty(masterDefineExtend.getDefMapTableName())){
|
// 租户二维表
|
if(Objects.equals(masterDefineExtend.getDefMapType(), "15")){
|
return tenantTwoDimensional(masterDefineExtend, p);
|
}
|
// 通用二维表
|
else{
|
return adminTwoDimensional(masterDefineExtend, p);
|
}
|
}
|
// 普通一维主数据
|
else{
|
// 租户一维表
|
if(Objects.equals(masterDefineExtend.getDefType(), "0")){
|
return tenantOneDimensional(masterDefineExtend, p);
|
}
|
// 通用一维表
|
else{
|
return adminOneDimensional(masterDefineExtend, p);
|
}
|
}
|
}
|
|
MasterDefinesExtend selectDefAndMapOne(String code){
|
List<MasterDefinesExtend> masterDefinesExtends = masterDefineMapper.selectDefAndMap(MasterDefine.of(code));
|
if(ObjectUtil.empty(masterDefinesExtends)){
|
return null;
|
}else{
|
return masterDefinesExtends.stream().findFirst().orElse(null);
|
}
|
}
|
|
/**
|
* 管理中心 一维、二维
|
* @param p
|
* @return
|
*/
|
protected abstract R adminOneDimensional(MasterDefinesExtend masterDefine, P p);
|
protected abstract R adminTwoDimensional(MasterDefinesExtend masterDefine, P p);
|
|
/**
|
* 租户 一维、二维
|
* @param p
|
* @return
|
*/
|
protected abstract R tenantOneDimensional(MasterDefinesExtend masterDefine, P p);
|
protected abstract R tenantTwoDimensional(MasterDefinesExtend masterDefine, P p);
|
}
|