Commit 58867c4e by s_guodong

处理码表值

parent aa204af7
...@@ -4,6 +4,7 @@ import com.brilliance.mda.runtime.annotation.Transaction; ...@@ -4,6 +4,7 @@ import com.brilliance.mda.runtime.annotation.Transaction;
import com.brilliance.mda.runtime.mda.*; import com.brilliance.mda.runtime.mda.*;
import com.brilliance.mda.runtime.mda.impl.EnvConfig; import com.brilliance.mda.runtime.mda.impl.EnvConfig;
import com.brilliance.mda.runtime.mda.snapshot.SnapshotService; 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 com.brilliance.mda.runtime.request.BaseVO;
import java.util.*; import java.util.*;
...@@ -260,7 +261,7 @@ public class MdaContext implements IContext { ...@@ -260,7 +261,7 @@ public class MdaContext implements IContext {
// 获取模板内容 // 获取模板内容
String templateContent = snapshotService.getTemplateContent(panelPath); String templateContent = snapshotService.getTemplateContent(panelPath);
// 获取填充值的key // 获取填充值的key
Set<String> keySet = snapshotService.getKeySet(); Set<ValueVo> keySet = snapshotService.getKeySet();
// 获取填充的值 // 获取填充的值
Map<String, Object> valueMap = snapshotService.getValueMap(keySet, parent); Map<String, Object> valueMap = snapshotService.getValueMap(keySet, parent);
if (this.display != null) { if (this.display != null) {
......
package com.brilliance.mda.runtime.mda.snapshot; package com.brilliance.mda.runtime.mda.snapshot;
import com.brilliance.mda.runtime.mda.IModule; 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.pack.PackDocumentBo;
import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.DocumentBo; import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.DocumentBo;
...@@ -28,7 +29,7 @@ public interface SnapshotService { ...@@ -28,7 +29,7 @@ public interface SnapshotService {
* @param parent * @param parent
* @return * @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 { ...@@ -47,9 +48,9 @@ public interface SnapshotService {
PackDocumentBo packTemplate(DocumentBo documentBo); PackDocumentBo packTemplate(DocumentBo documentBo);
/** /**
* 获取需要填充值的key * 获取需要填充值的实体
* *
* @return * @return
*/ */
Set<String> getKeySet(); Set<ValueVo> getKeySet();
} }
package com.brilliance.mda.runtime.mda.snapshot; package com.brilliance.mda.runtime.mda.snapshot;
import com.brilliance.mda.runtime.mda.IModule; 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.pack.*;
import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.*; import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.*;
import com.brilliance.mda.runtime.mda.util.DateUtil; import com.brilliance.mda.runtime.mda.util.DateUtil;
...@@ -28,7 +29,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -28,7 +29,7 @@ public class SnapshotServiceImpl implements SnapshotService {
protected static final String DISPLAY_TEMPLATE_PATH = "displayTemplate/"; 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 @Override
public String getTemplateContent(String panelPath) { public String getTemplateContent(String panelPath) {
...@@ -109,7 +110,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -109,7 +110,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) { for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl(); text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
keySet.add(text); keySet.add(new ValueVo(text));
break; break;
} }
} }
...@@ -127,7 +128,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -127,7 +128,7 @@ public class SnapshotServiceImpl implements SnapshotService {
String value = customAttributes.getLabelId(); String value = customAttributes.getLabelId();
if (StringUtils.isBlank(value)) { if (StringUtils.isBlank(value)) {
value = customAttributes.getFieldUrl(); value = customAttributes.getFieldUrl();
keySet.add(value); keySet.add(new ValueVo(value));
data.setValue("${" + value + "}"); data.setValue("${" + value + "}");
} else { } else {
// /bctp/LT000070/ // /bctp/LT000070/
...@@ -145,7 +146,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -145,7 +146,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) { for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl(); text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
keySet.add(text); keySet.add(new ValueVo(text, null, customAttribute.getCodeTable()));
break; break;
} }
} }
...@@ -161,7 +162,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -161,7 +162,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) { for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl(); text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
keySet.add(text + ":" + textboxBo.getFormat()); keySet.add(new ValueVo(text, textboxBo.getFormat(), null));
break; break;
} }
} }
...@@ -178,7 +179,7 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -178,7 +179,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for (CustomAttributes customAttribute : customAttributes) { for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl(); text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
keySet.add(text); keySet.add(new ValueVo(text));
break; break;
} }
} }
...@@ -202,21 +203,21 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -202,21 +203,21 @@ public class SnapshotServiceImpl implements SnapshotService {
@Override @Override
public Set<String> getKeySet() { public Set<ValueVo> getKeySet() {
return keySet; return keySet;
} }
@Override @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(); Map<String, Object> valueMap = new HashMap();
IModule root = getRoot(parent); IModule root = getRoot(parent);
for (String key : keySet) { for (ValueVo valueVo : keySet) {
if (key.startsWith("\\")) { if (valueVo.getKey().startsWith("\\")) {
// 从根节点获取值 // 从根节点获取值
getValueFromModule(valueMap, root, key); getValueFromModule(valueMap, root, valueVo);
} else { } else {
getValueFromModule(valueMap, parent, key); getValueFromModule(valueMap, parent, valueVo);
} }
} }
return valueMap; return valueMap;
...@@ -242,16 +243,11 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -242,16 +243,11 @@ public class SnapshotServiceImpl implements SnapshotService {
* *
* @param valueMap * @param valueMap
* @param parent * @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 originKey = key;
String format = "";
if (key.contains(":")) {
String[] split = key.split(":");
originKey = split[0];
format = split[1];
}
if (key.startsWith("\\")) { if (key.startsWith("\\")) {
key = key.substring(1); key = key.substring(1);
} }
...@@ -274,9 +270,19 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -274,9 +270,19 @@ public class SnapshotServiceImpl implements SnapshotService {
} }
} }
if (value != null && StringUtils.isNotBlank(format)) { 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("/", "-")); value = DateUtil.format((Date) value, format.replaceAll("/", "-"));
} }
}
valueMap.put(originKey, value == null ? "" : value); 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 { ...@@ -22,4 +22,7 @@ public class CustomAttributes {
@XmlAttribute(name = "fieldUrl") @XmlAttribute(name = "fieldUrl")
private String 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