Commit 58867c4e by s_guodong

处理码表值

parent aa204af7
......@@ -4,6 +4,7 @@ import com.brilliance.mda.runtime.annotation.Transaction;
import com.brilliance.mda.runtime.mda.*;
import com.brilliance.mda.runtime.mda.impl.EnvConfig;
import com.brilliance.mda.runtime.mda.snapshot.SnapshotService;
import com.brilliance.mda.runtime.mda.snapshot.bo.ValueVo;
import com.brilliance.mda.runtime.request.BaseVO;
import java.util.*;
......@@ -260,7 +261,7 @@ public class MdaContext implements IContext {
// 获取模板内容
String templateContent = snapshotService.getTemplateContent(panelPath);
// 获取填充值的key
Set<String> keySet = snapshotService.getKeySet();
Set<ValueVo> keySet = snapshotService.getKeySet();
// 获取填充的值
Map<String, Object> valueMap = snapshotService.getValueMap(keySet, parent);
if (this.display != null) {
......
package com.brilliance.mda.runtime.mda.snapshot;
import com.brilliance.mda.runtime.mda.IModule;
import com.brilliance.mda.runtime.mda.snapshot.bo.ValueVo;
import com.brilliance.mda.runtime.mda.snapshot.bo.pack.PackDocumentBo;
import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.DocumentBo;
......@@ -28,7 +29,7 @@ public interface SnapshotService {
* @param parent
* @return
*/
Map<String, Object> getValueMap(Set<String> keySet, IModule parent);
Map<String, Object> getValueMap(Set<ValueVo> keySet, IModule parent);
/**
* 解析标准模板
......@@ -47,9 +48,9 @@ public interface SnapshotService {
PackDocumentBo packTemplate(DocumentBo documentBo);
/**
* 获取需要填充值的key
* 获取需要填充值的实体
*
* @return
*/
Set<String> getKeySet();
Set<ValueVo> getKeySet();
}
package com.brilliance.mda.runtime.mda.snapshot;
import com.brilliance.mda.runtime.mda.IModule;
import com.brilliance.mda.runtime.mda.snapshot.bo.ValueVo;
import com.brilliance.mda.runtime.mda.snapshot.bo.pack.*;
import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.*;
import com.brilliance.mda.runtime.mda.util.DateUtil;
......@@ -28,7 +29,7 @@ public class SnapshotServiceImpl implements SnapshotService {
protected static final String DISPLAY_TEMPLATE_PATH = "displayTemplate/";
private static final Set<String> keySet = new HashSet<>();
private static final Set<ValueVo> keySet = new HashSet<>();
@Override
public String getTemplateContent(String panelPath) {
......@@ -109,7 +110,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(text);
keySet.add(new ValueVo(text));
break;
}
}
......@@ -127,7 +128,7 @@ public class SnapshotServiceImpl implements SnapshotService {
String value = customAttributes.getLabelId();
if (StringUtils.isBlank(value)) {
value = customAttributes.getFieldUrl();
keySet.add(value);
keySet.add(new ValueVo(value));
data.setValue("${" + value + "}");
} else {
// /bctp/LT000070/
......@@ -145,7 +146,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(text);
keySet.add(new ValueVo(text, null, customAttribute.getCodeTable()));
break;
}
}
......@@ -161,7 +162,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(text + ":" + textboxBo.getFormat());
keySet.add(new ValueVo(text, textboxBo.getFormat(), null));
break;
}
}
......@@ -178,7 +179,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(text);
keySet.add(new ValueVo(text));
break;
}
}
......@@ -202,21 +203,21 @@ public class SnapshotServiceImpl implements SnapshotService {
@Override
public Set<String> getKeySet() {
public Set<ValueVo> getKeySet() {
return keySet;
}
@Override
public Map<String, Object> getValueMap(Set<String> keySet, IModule parent) {
public Map<String, Object> getValueMap(Set<ValueVo> keySet, IModule parent) {
Map<String, Object> valueMap = new HashMap();
IModule root = getRoot(parent);
for (String key : keySet) {
if (key.startsWith("\\")) {
for (ValueVo valueVo : keySet) {
if (valueVo.getKey().startsWith("\\")) {
// 从根节点获取值
getValueFromModule(valueMap, root, key);
getValueFromModule(valueMap, root, valueVo);
} else {
getValueFromModule(valueMap, parent, key);
getValueFromModule(valueMap, parent, valueVo);
}
}
return valueMap;
......@@ -242,16 +243,11 @@ public class SnapshotServiceImpl implements SnapshotService {
*
* @param valueMap
* @param parent
* @param key
* @param valueVo
*/
private void getValueFromModule(Map<String, Object> valueMap, IModule parent, String key) {
private void getValueFromModule(Map<String, Object> valueMap, IModule parent, ValueVo valueVo) {
String key = valueVo.getKey();
String originKey = key;
String format = "";
if (key.contains(":")) {
String[] split = key.split(":");
originKey = split[0];
format = split[1];
}
if (key.startsWith("\\")) {
key = key.substring(1);
}
......@@ -274,9 +270,19 @@ public class SnapshotServiceImpl implements SnapshotService {
}
}
if (value != null && StringUtils.isNotBlank(format)) {
value = DateUtil.format((Date) value, format.replaceAll("/", "-"));
if (value != null) {
String format = valueVo.getFormat();
String codeTable = valueVo.getCodeTable();
// 从码表中转换
if (StringUtils.isNotBlank(codeTable)) {
value = MdaUtils.getCodetableLabel(codeTable, (String) value);
}
// 时间格式化
if (StringUtils.isNotBlank(format) && value instanceof Date) {
value = DateUtil.format((Date) value, format.replaceAll("/", "-"));
}
}
valueMap.put(originKey, value == null ? "" : value);
}
......
package com.brilliance.mda.runtime.mda.snapshot.bo;
import lombok.Data;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/21
*/
@Data
public class ValueVo {
private String key;
private String format;
private String codeTable;
public ValueVo(String key) {
this.key = key;
}
public ValueVo(String key, String format, String codeTable) {
this.key = key;
this.format = format;
this.codeTable = codeTable;
}
}
......@@ -22,4 +22,7 @@ public class CustomAttributes {
@XmlAttribute(name = "fieldUrl")
private String fieldUrl;
@XmlAttribute(name = "codeTable")
private String codeTable;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment