493 lines
25 KiB
Java
493 lines
25 KiB
Java
package com.engine.salary.formlua.util;
|
||
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.weaver.common.form.component.base.ComponentType;
|
||
import com.weaver.excel.formula.api.entity.DataOption;
|
||
import com.weaver.excel.formula.api.entity.FormulaVar;
|
||
import com.weaver.excel.formula.entity.parameter.DataType;
|
||
import com.weaver.excel.formula.entity.parameter.ParamFactory;
|
||
import com.weaver.excel.formula.entity.standard.front.CurrentVar;
|
||
import com.weaver.teams.domain.user.DataCollectionEmployee;
|
||
import com.weaver.teams.util.StringUtils;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.regex.Matcher;
|
||
import java.util.regex.Pattern;
|
||
|
||
public class ExcelStandardUtil {
|
||
protected static final Logger logger = LoggerFactory.getLogger(ExcelStandardUtil.class);
|
||
|
||
public static Map<String,Object> replaceAllParam(String sql, List<FormulaVar> localVars,List<FormulaVar> dataVars, DataCollectionEmployee employee){
|
||
if(null!=localVars){
|
||
for (FormulaVar formulaVar:localVars){
|
||
if(StringUtils.isNotEmpty(formulaVar.getDataId()) && StringUtils.isEmpty(formulaVar.getFormId())){
|
||
formulaVar.setFormId(formulaVar.getDataId());
|
||
}
|
||
if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_department")){
|
||
formulaVar.setType("department");
|
||
formulaVar.setComponentKey(ComponentType.Department.toString());
|
||
}
|
||
if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_superior")){
|
||
formulaVar.setType("employee");
|
||
formulaVar.setComponentKey(ComponentType.Employee.toString());
|
||
}
|
||
}
|
||
}
|
||
|
||
Map<String,Object> dataMap=new HashMap<>();
|
||
Map<String,DataType> paramKeyMap=new HashMap<>();
|
||
//正则表达式匹配所有用 { } 括号包起来的变量,然后跟参数列表中的参数一一对应做替换
|
||
String partternStr="\\{.+?\\}{1}?";
|
||
Pattern pt=Pattern.compile(partternStr);
|
||
Matcher matcher=pt.matcher(sql);
|
||
|
||
int loop=0;
|
||
//替换逻辑
|
||
while (matcher.find()){
|
||
String matherString=matcher.group();
|
||
//替换特殊字符
|
||
matherString=matherString.replace("{","");
|
||
matherString=matherString.replace("}","");
|
||
matherString=matherString.replace("(","\\(");
|
||
matherString=matherString.replace(")","\\)");
|
||
matherString=matherString.replaceAll("\\+","\\\\+");
|
||
matherString=matherString.replaceAll("\\-","\\\\-");
|
||
matherString=matherString.replaceAll("\\*","\\\\*");
|
||
matherString=matherString.replaceAll("\\/","\\\\/");
|
||
if(localVars!=null&&loop<localVars.size()){
|
||
FormulaVar localFormulaVar=localVars.get(loop);
|
||
//如果参数异常,获取Key为空,根据数据中相应的值做判断,判断是什么类型的控件
|
||
String key=null;
|
||
if(localFormulaVar.getOptionId()!=null && StringUtils.isNotEmpty(localFormulaVar.getOptionId())){
|
||
key="key"+localFormulaVar.getOptionId();
|
||
}else if(localFormulaVar.getFieldId()!=null){
|
||
key="key"+localFormulaVar.getFieldId();
|
||
}else if(localFormulaVar.getFormId()!=null){
|
||
key="key"+localFormulaVar.getFormId();
|
||
}else if(localFormulaVar.getId() !=null){
|
||
key="key"+localFormulaVar.getId();
|
||
}else if(localFormulaVar.getId()!=null && localFormulaVar.getId().equalsIgnoreCase(CurrentVar.current_user.toString())){
|
||
key="key"+localFormulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(localFormulaVar.getId()!=null && localFormulaVar.getId().equalsIgnoreCase(CurrentVar.current_department.toString())){
|
||
key="key"+localFormulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(localFormulaVar.getId()!=null && localFormulaVar.getId().equalsIgnoreCase(CurrentVar.current_position.toString())){
|
||
key="key"+localFormulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(localFormulaVar.getId()!=null && localFormulaVar.getId().equalsIgnoreCase(CurrentVar.current_superior.toString())){
|
||
key="key"+localFormulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}
|
||
if(key!=null){
|
||
sql=sql.replaceFirst(matherString,key);
|
||
DataType dataType=transFormulaVarToDataType(localFormulaVar,dataVars,employee);
|
||
if(dataType!=null){
|
||
if(!paramKeyMap.containsKey(key)){
|
||
paramKeyMap.put(key,dataType);
|
||
}else{
|
||
logger.info("存在同名参数:"+key+"-->"+JSON.toJSONString(dataType));
|
||
}
|
||
}else{
|
||
String typeKey=localFormulaVar.getProperKey();
|
||
if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){
|
||
typeKey=localFormulaVar.getFieldType();
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getType())){
|
||
typeKey=localFormulaVar.getType();
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){
|
||
typeKey=localFormulaVar.getFieldType();
|
||
localFormulaVar.setComponentKey(localFormulaVar.getFieldType());
|
||
}
|
||
dataType.setDataType(ExcelParamUtil.findDataType(typeKey));
|
||
dataType.setFieldId(localFormulaVar.getFieldId());
|
||
dataType.setFormId(StringUtils.isNotEmpty(localFormulaVar.getFormId())?Long.parseLong(localFormulaVar.getFormId()):null);
|
||
try {
|
||
dataType.setModule(localFormulaVar.getModule());
|
||
} catch (IllegalArgumentException e) {
|
||
logger.error("err",e);
|
||
dataType.setModule(localFormulaVar.getModule());
|
||
}
|
||
dataType.setContent("");
|
||
if(!paramKeyMap.containsKey(key)){
|
||
paramKeyMap.put(key,dataType);
|
||
}else{
|
||
logger.info("存在同名参数:"+key+"-->"+JSON.toJSONString(dataType));
|
||
}
|
||
}
|
||
}
|
||
loop++;
|
||
}
|
||
}
|
||
// if(loop!=localVars.size()){
|
||
// throw new RuntimeException("参数列表与执行语句不一致");
|
||
// }
|
||
dataMap.put("param",paramKeyMap);
|
||
dataMap.put("sql",sql);
|
||
return dataMap;
|
||
}
|
||
|
||
public static Map<String,Object> replaceAllParamForTest(String sql, List<FormulaVar> formulaVars, DataCollectionEmployee employee){
|
||
if(null==formulaVars){
|
||
return null;
|
||
}
|
||
for (FormulaVar formulaVar:formulaVars){
|
||
if(StringUtils.isNotEmpty(formulaVar.getDataId()) && StringUtils.isEmpty(formulaVar.getFormId())){
|
||
formulaVar.setFormId(formulaVar.getDataId());
|
||
if(StringUtils.isNotEmpty(formulaVar.getType()) && StringUtils.isEmpty(formulaVar.getComponentKey())){
|
||
if(formulaVar.getType().equalsIgnoreCase("operator") || formulaVar.getType().equalsIgnoreCase("employee")){
|
||
formulaVar.setComponentKey("");
|
||
}
|
||
}
|
||
}
|
||
if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_department")){
|
||
formulaVar.setType("department");
|
||
formulaVar.setComponentKey("Department");
|
||
}
|
||
if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_superior")){
|
||
formulaVar.setType("employee");
|
||
formulaVar.setComponentKey("Employee");
|
||
}
|
||
}
|
||
Map<String,Object> dataMap=new HashMap<>();
|
||
Map<String,DataType> paramKeyMap=new HashMap<>();
|
||
//正则表达式匹配所有用 { } 括号包起来的变量,然后跟参数列表中的参数一一对应做替换
|
||
String partternStr="\\{.+?\\}{1}?";
|
||
Pattern pt=Pattern.compile(partternStr);
|
||
Matcher matcher=pt.matcher(sql);
|
||
|
||
int loop=0;
|
||
//替换逻辑
|
||
while (matcher.find()){
|
||
String matherString=matcher.group();
|
||
//替换特殊字符
|
||
matherString=matherString.replace("{","");
|
||
matherString=matherString.replace("}","");
|
||
matherString=matherString.replace("(","\\(");
|
||
matherString=matherString.replace(")","\\)");
|
||
matherString=matherString.replaceAll("\\+","\\\\+");
|
||
matherString=matherString.replaceAll("\\-","\\\\-");
|
||
matherString=matherString.replaceAll("\\*","\\\\*");
|
||
matherString=matherString.replaceAll("\\/","\\\\/");
|
||
if(formulaVars!=null&&loop<formulaVars.size()){
|
||
FormulaVar formulaVar=formulaVars.get(loop);
|
||
//如果参数异常,获取Key为空,根据数据中相应的值做判断,判断是什么类型的控件
|
||
String key=null;
|
||
if(formulaVar.getOptionId()!=null && StringUtils.isNotEmpty(formulaVar.getOptionId())){
|
||
key="key"+formulaVar.getOptionId();
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(formulaVar.getFieldId()!=null){
|
||
key="key"+formulaVar.getFieldId();
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(formulaVar.getFormId()!=null){
|
||
key="key"+formulaVar.getFormId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(StringUtils.isNotEmpty(formulaVar.getFieldType())){
|
||
if(formulaVar.getFieldType().equalsIgnoreCase("option")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}
|
||
}else if(formulaVar.getId()!=null){
|
||
if(formulaVar.getId().equalsIgnoreCase("current_user") || formulaVar.getId().equalsIgnoreCase("current_superior") || formulaVar.getId().equalsIgnoreCase("current_department")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}else if(formulaVar.getType()!=null && formulaVar.getType().equalsIgnoreCase("department")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
//人员选项常量
|
||
}else if(formulaVar.getType()!=null && formulaVar.getType().equalsIgnoreCase("employee")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}
|
||
|
||
}else if(StringUtils.isNotEmpty(formulaVar.getType())){
|
||
/**
|
||
* 部门选项常量
|
||
*/
|
||
if(formulaVar.getType().equalsIgnoreCase("department")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
//人员选项常量
|
||
}else if(formulaVar.getType().equalsIgnoreCase("employee")){
|
||
key="key"+formulaVar.getId()+"";
|
||
sql=sql.replaceFirst(matherString,key);
|
||
}
|
||
}
|
||
if(key!=null){
|
||
if(!paramKeyMap.containsKey(key)){
|
||
paramKeyMap.put(key,transFormulaVarToDataTypeTesy(formulaVar,employee));
|
||
}
|
||
}
|
||
loop++;
|
||
}
|
||
}
|
||
if(loop!=formulaVars.size()){
|
||
throw new RuntimeException("参数列表与执行语句不一致");
|
||
}
|
||
dataMap.put("param",paramKeyMap);
|
||
dataMap.put("sql",sql);
|
||
logger.info("函数校验参数:"+JSON.toJSONString(dataMap));
|
||
return dataMap;
|
||
}
|
||
|
||
private static DataType transFormulaVarToDataTypeTesy(FormulaVar formulaVar,DataCollectionEmployee employee){
|
||
DataType dataType =new DataType();
|
||
ParamFactory paramFactory=ParamFactory.getInstance();
|
||
dataType.setContent(formulaVar.getContent());
|
||
dataType.setText(formulaVar.getContent());
|
||
String typeKey=formulaVar.getProperKey();
|
||
if(StringUtils.isNotEmpty(formulaVar.getFieldType()) && StringUtils.isEmpty(typeKey)){//选项型取值
|
||
typeKey=formulaVar.getFieldType();
|
||
}else if(StringUtils.isNotEmpty(formulaVar.getType()) && StringUtils.isEmpty(typeKey)){//当前操作人取值
|
||
typeKey=formulaVar.getType();
|
||
}else if(StringUtils.isNotEmpty(formulaVar.getFieldType()) && StringUtils.isEmpty(typeKey)){
|
||
typeKey=formulaVar.getFieldType();
|
||
formulaVar.setComponentKey(formulaVar.getFieldType());
|
||
}
|
||
switch (ExcelParamUtil.findDataType(typeKey)){
|
||
case DataType.DATE:
|
||
dataType.setContent(paramFactory.getDateTimeValue());
|
||
dataType.setText(paramFactory.getDateTimeValue());
|
||
dataType.setDataType(DataType.STRING);
|
||
dataType.setComponentKey("DateComponent");
|
||
break;
|
||
case DataType.STRING:
|
||
dataType.setContent(paramFactory.getCharValue());
|
||
dataType.setText(paramFactory.getCharValue());
|
||
dataType.setDataType(DataType.STRING);
|
||
dataType.setComponentKey("Text");
|
||
break;
|
||
case DataType.NUMBER:
|
||
dataType.setContent(paramFactory.getDoubleValue());
|
||
dataType.setText(paramFactory.getDoubleValue()+"");
|
||
dataType.setDataType(DataType.NUMBER);
|
||
dataType.setComponentKey("NumberComponent");
|
||
break;
|
||
case DataType.OPTION:
|
||
dataType.setContent(paramFactory.getSelectValue());
|
||
dataType.setText(paramFactory.getSelectValue());
|
||
dataType.setScore(paramFactory.getDoubleValue());
|
||
dataType.setDataType(DataType.OPTION);
|
||
|
||
if(formulaVar.getType()!=null && (formulaVar.getType().equalsIgnoreCase("employee") || formulaVar.getType().equalsIgnoreCase("operator")) || (formulaVar.getProperKey()!=null && formulaVar.getProperKey().equalsIgnoreCase("employee"))){
|
||
dataType.setContent(employee.getId());
|
||
dataType.setComponentKey("Employee");
|
||
if(formulaVar.getId()!=null && formulaVar.getId().equalsIgnoreCase("current_superior")){
|
||
dataType.setContent(employee.getSuperiorId());
|
||
}
|
||
}else if(formulaVar.getType()!=null && (formulaVar.getType().equalsIgnoreCase(ComponentType.Department.toString()) || formulaVar.getType().equalsIgnoreCase(ComponentType.Department.toString())) || (formulaVar.getProperKey()!=null && formulaVar.getProperKey().equalsIgnoreCase(ComponentType.Department.toString()))){
|
||
dataType.setContent(employee.getDepartmentId());
|
||
dataType.setComponentKey("Department");
|
||
}else{
|
||
if(formulaVar.getFieldType()!=null && formulaVar.getFieldType().equalsIgnoreCase("Employee")){
|
||
formulaVar.setComponentKey("Employee");
|
||
dataType.setComponentKey("Employee");
|
||
}else{
|
||
dataType.setComponentKey("RadioBox");
|
||
}
|
||
}
|
||
|
||
break;
|
||
case DataType.DATASOURCE:
|
||
dataType.setContent(paramFactory.getSelectValue());
|
||
dataType.setText(paramFactory.getSelectValue());
|
||
dataType.setScore(paramFactory.getDoubleValue());
|
||
dataType.setDataType(DataType.OPTION);
|
||
dataType.setComponentKey("RadioBox");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if(StringUtils.isNotEmpty(formulaVar.getDataType())){
|
||
dataType.setDataType(formulaVar.getDataType());
|
||
}
|
||
|
||
dataType.setFieldId(formulaVar.getFieldId()+"");
|
||
dataType.setFormId(formulaVar.getFormId()!=null?Long.parseLong(formulaVar.getFormId()):null);
|
||
dataType.setEmployee(employee);
|
||
if(StringUtils.isNotEmpty(formulaVar.getModule())){
|
||
try {
|
||
try {
|
||
dataType.setModule(formulaVar.getModule());
|
||
} catch (IllegalArgumentException e) {
|
||
logger.error("err",e);
|
||
dataType.setModule(formulaVar.getModule());
|
||
}
|
||
} catch (IllegalArgumentException e) {
|
||
logger.error("err",e);
|
||
dataType.setModule(formulaVar.getModule());
|
||
}
|
||
|
||
}
|
||
dataType.setName(formulaVar.getTitle());
|
||
if(StringUtils.isEmpty(dataType.getName())){
|
||
dataType.setName(formulaVar.getName());
|
||
}
|
||
return dataType;
|
||
}
|
||
|
||
private static DataType transFormulaVarToDataType(FormulaVar localFormulaVar,List<FormulaVar> dataVars,DataCollectionEmployee employee){
|
||
DataType dataType =new DataType();
|
||
if(localFormulaVar == null){
|
||
return null;
|
||
}
|
||
|
||
String typeKey=localFormulaVar.getProperKey();
|
||
if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){
|
||
typeKey=localFormulaVar.getFieldType();
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getType())){
|
||
typeKey=localFormulaVar.getType();
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){
|
||
typeKey=localFormulaVar.getFieldType();
|
||
localFormulaVar.setComponentKey(localFormulaVar.getFieldType());
|
||
}
|
||
logger.info(localFormulaVar.getId()+"typeKey=:"+typeKey);
|
||
switch (ExcelParamUtil.findDataType(typeKey)){
|
||
case DataType.DATE:
|
||
dataType.setDataType(DataType.STRING);
|
||
setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field");
|
||
if(dataType.getContent()==null){
|
||
dataType.setContent("");
|
||
}
|
||
break;
|
||
case DataType.STRING:
|
||
dataType.setDataType(DataType.STRING);
|
||
setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field");
|
||
if(dataType.getContent()==null){
|
||
dataType.setContent("");
|
||
}
|
||
break;
|
||
case DataType.NUMBER:
|
||
dataType.setDataType(DataType.NUMBER);
|
||
setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field");
|
||
break;
|
||
case DataType.OPTION:
|
||
logger.info("函数构建选项型:"+JSON.toJSONString(localFormulaVar));
|
||
dataType.setDataType(DataType.OPTION);
|
||
setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"option");
|
||
if(dataType.getContent() == null){
|
||
dataType.setContent(localFormulaVar.getId()!=null?localFormulaVar.getId():localFormulaVar.getOptionId());
|
||
dataType.setText(dataType.getContent()+"");
|
||
}
|
||
//当前操作人赋值
|
||
if(localFormulaVar.getId()!=null){
|
||
switch (localFormulaVar.getId()){
|
||
case "current_user":
|
||
dataType.setContent(employee.getId());
|
||
dataType.setOptionContent(employee.getName());
|
||
break;
|
||
case "current_superior":
|
||
dataType.setContent(employee.getSuperiorId());
|
||
break;
|
||
case "current_department":
|
||
dataType.setContent(employee.getDepartmentId());
|
||
break;
|
||
case "current_position":
|
||
dataType.setContent(employee.getPositionId());
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
logger.info("当前操作人赋值完成:"+JSON.toJSONString(dataType));
|
||
}
|
||
break;
|
||
case DataType.DATASOURCE:
|
||
dataType.setDataType(DataType.DATASOURCE);
|
||
setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"option");
|
||
break;
|
||
default:
|
||
logger.info("未匹配到参数类型:"+(JSON.toJSONString(localFormulaVar)));
|
||
break;
|
||
}
|
||
if(StringUtils.isNotEmpty(localFormulaVar.getDataType())){
|
||
dataType.setDataType(localFormulaVar.getDataType());
|
||
}
|
||
if(StringUtils.isEmpty(dataType.getComponentKey())){
|
||
if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){
|
||
dataType.setComponentKey(localFormulaVar.getFieldType());
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getProperKey())){
|
||
dataType.setComponentKey(localFormulaVar.getProperKey());
|
||
}else if(StringUtils.isNotEmpty(localFormulaVar.getComponentKey())){
|
||
dataType.setComponentKey(localFormulaVar.getComponentKey());
|
||
}
|
||
}
|
||
dataType.setFieldId(localFormulaVar.getFieldId()+"");
|
||
dataType.setFormId(localFormulaVar.getFormId()!=null?Long.parseLong(localFormulaVar.getFormId()):null);
|
||
dataType.setEmployee(employee);
|
||
if(StringUtils.isNotEmpty(localFormulaVar.getModule())){
|
||
try {
|
||
dataType.setModule(localFormulaVar.getModule());
|
||
} catch (IllegalArgumentException e) {
|
||
logger.error("err",e);
|
||
dataType.setModule(localFormulaVar.getModule());
|
||
}
|
||
}
|
||
dataType.setName(localFormulaVar.getTitle()!=null?localFormulaVar.getTitle():localFormulaVar.getName());
|
||
logger.info("构建值完毕:"+JSON.toJSONString(dataType));
|
||
return dataType;
|
||
}
|
||
private static void setContent(DataType dataType,String typeKey,String sourceVar,List<FormulaVar> targetVarList,String type){
|
||
if(sourceVar==null){
|
||
return ;
|
||
}
|
||
for (FormulaVar loopVar:targetVarList){
|
||
switch (type){
|
||
case "field":
|
||
if(sourceVar.equalsIgnoreCase(loopVar.getFieldId())){
|
||
dataType.setContent(loopVar.getContent()!=null?loopVar.getContent():"");
|
||
dataType.setText(dataType.getContent()+"");
|
||
if(StringUtils.isNotEmpty(loopVar.getsFormId())){
|
||
dataType.setSubFormId(Long.parseLong(loopVar.getsFormId()));
|
||
}
|
||
dataType.setComponentKey(loopVar.getComponentKey());
|
||
}else{
|
||
dataType.setComponentKey(typeKey);
|
||
}
|
||
break;
|
||
case "form":
|
||
if(sourceVar.equalsIgnoreCase(loopVar.getFormId())){
|
||
dataType.setContent(loopVar.getContent());
|
||
}
|
||
break;
|
||
case "option":
|
||
if(sourceVar.equalsIgnoreCase(loopVar.getFieldId())){
|
||
dataType.setContent(loopVar.getContent());
|
||
if(dataType.getContent()==null){
|
||
dataType.setContent(loopVar.getOptionId());
|
||
dataType.setText(loopVar.getOptionId());
|
||
}
|
||
//常量
|
||
if(StringUtils.isNotEmpty(loopVar.getOptionContent())){
|
||
dataType.setOptionContent(loopVar.getOptionContent());
|
||
}else if(loopVar.getDataOptionList()!=null && loopVar.getDataOptionList().size()>0){
|
||
String optionContents="";
|
||
List<DataOption> dataOptions=loopVar.getDataOptionList();
|
||
for(DataOption dataOption:dataOptions){
|
||
optionContents+=dataOption.getOptionContent()+",";
|
||
}
|
||
if(optionContents.lastIndexOf(",")>0){
|
||
optionContents=optionContents.substring(0,optionContents.lastIndexOf(","));
|
||
}
|
||
dataType.setOptionContent(optionContents);
|
||
}else {//变量
|
||
dataType.setOptionContent(loopVar.getContent());
|
||
}
|
||
|
||
dataType.setScore(loopVar.getScore());
|
||
if(StringUtils.isNotEmpty(loopVar.getsFormId())){
|
||
dataType.setSubFormId(Long.parseLong(loopVar.getsFormId()));
|
||
}
|
||
dataType.setComponentKey(loopVar.getComponentKey());
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|