Commit d8b7458b by s_guodong

checkbox处理

parent 58867c4e
package com.brilliance.mda.runtime.mda.snapshot;
import com.brilliance.mda.runtime.mda.IModule;
import com.brilliance.mda.runtime.mda.snapshot.bo.AttributeEnum;
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.*;
......@@ -81,11 +82,15 @@ public class SnapshotServiceImpl implements SnapshotService {
List<PackTextboxBo> textboxBoList = new ArrayList<>();
packDivBo.setTextboxBoList(textboxBoList);
List<TextboxBo> textboxList = new ArrayList<>();
List<LabelBo> labelList = new ArrayList<>();
List<TextboxBo> xcomboboxList = new ArrayList<>();
List<TextboxBo> xdateboxList = new ArrayList<>();
List<TextboxBo> xdecimalboxList = new ArrayList<>();
List<PackCheckboxBo> checkboxBoList = new ArrayList<>();
packDivBo.setCheckboxBoList(checkboxBoList);
List<TextboxBo> textboxList;
List<LabelBo> labelList;
List<TextboxBo> xcomboboxList;
List<TextboxBo> xdateboxList;
List<TextboxBo> xdecimalboxList;
List<CheckboxBo> checkboxList = new ArrayList<>();
BorderlayoutBo borderlayoutBo = documentBo.getBorderlayoutBo();
if (borderlayoutBo != null) {
......@@ -96,24 +101,23 @@ public class SnapshotServiceImpl implements SnapshotService {
xcomboboxList = divBo.getXcomboboxList();
xdateboxList = divBo.getXdateboxList();
xdecimalboxList = divBo.getXdecimalboxList();
checkboxList = divBo.getCheckboxList();
} else {
textboxList = documentBo.getTextboxList();
labelList = documentBo.getLabelList();
xcomboboxList = documentBo.getXcomboboxList();
xdateboxList = documentBo.getXdateboxList();
xdecimalboxList = documentBo.getXdecimalboxList();
checkboxList = documentBo.getCheckboxList();
}
for (TextboxBo textboxBo : textboxList) {
List<CustomAttributes> customAttributes = textboxBo.getCustomAttributes();
String text = "";
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text));
break;
}
String text = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text));
}
PackTextboxBo data = new PackTextboxBo();
data.setText("${" + text + "}");
data.setStyle(textboxBo.getStyle());
......@@ -124,10 +128,10 @@ public class SnapshotServiceImpl implements SnapshotService {
for (LabelBo labelBo : labelList) {
PackLabelBo data = new PackLabelBo();
CustomAttributes customAttributes = labelBo.getCustomAttributes();
String value = customAttributes.getLabelId();
List<CustomAttributes> customAttributes = labelBo.getCustomAttributes();
String value = getAttributeValue(customAttributes, AttributeEnum.LABELID);
if (StringUtils.isBlank(value)) {
value = customAttributes.getFieldUrl();
value = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
keySet.add(new ValueVo(value));
data.setValue("${" + value + "}");
} else {
......@@ -142,14 +146,12 @@ public class SnapshotServiceImpl implements SnapshotService {
for (TextboxBo textboxBo : xcomboboxList) {
List<CustomAttributes> customAttributes = textboxBo.getCustomAttributes();
String text = "";
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text, null, customAttribute.getCodeTable()));
break;
}
String text = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text, null, getAttributeValue(customAttributes, AttributeEnum.CODETABLE)));
}
PackComboboxBo data = new PackComboboxBo();
data.setText("${" + text + "}");
data.setStyle(textboxBo.getStyle());
......@@ -158,13 +160,9 @@ public class SnapshotServiceImpl implements SnapshotService {
for (TextboxBo textboxBo : xdateboxList) {
List<CustomAttributes> customAttributes = textboxBo.getCustomAttributes();
String text = "";
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text, textboxBo.getFormat(), null));
break;
}
String text = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text, textboxBo.getFormat(), null));
}
PackDateboxBo data = new PackDateboxBo();
data.setText("${" + text + "}");
......@@ -175,13 +173,9 @@ public class SnapshotServiceImpl implements SnapshotService {
for (TextboxBo textboxBo : xdecimalboxList) {
List<CustomAttributes> customAttributes = textboxBo.getCustomAttributes();
String text = "";
for (CustomAttributes customAttribute : customAttributes) {
text = customAttribute.getFieldUrl();
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text));
break;
}
String text = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
if (StringUtils.isNotBlank(text)) {
keySet.add(new ValueVo(text));
}
PackDecimalboxBo data = new PackDecimalboxBo();
data.setText("${" + text + "}");
......@@ -189,6 +183,27 @@ public class SnapshotServiceImpl implements SnapshotService {
data.setFormat(textboxBo.getFormat());
decimalboxBoList.add(data);
}
for (CheckboxBo checkboxBo : checkboxList) {
PackCheckboxBo data = new PackCheckboxBo();
List<CustomAttributes> customAttributes = checkboxBo.getCustomAttributes();
String fieldUrl = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
String labelId = getAttributeValue(customAttributes, AttributeEnum.LABELID);
if (StringUtils.isBlank(labelId)) {
labelId = getAttributeValue(customAttributes, AttributeEnum.FIELDURL);
keySet.add(new ValueVo(labelId));
data.setLabel("${" + labelId + "}");
} else {
// /bctp/LT000070/
String[] split = labelId.substring(1, labelId.length() - 1).split("/");
String i18NString = MdaUtils.getI18NString(split[0], split[1]);
data.setLabel(i18NString);
}
data.setChecked("${" + fieldUrl + "}");
data.setStyle(checkboxBo.getStyle());
checkboxBoList.add(data);
}
// 组成xml需要的实体
PackBorderlayoutBo packBorderlayoutBo = new PackBorderlayoutBo();
PackCenterBo packCenterBo = new PackCenterBo();
......@@ -281,10 +296,43 @@ public class SnapshotServiceImpl implements SnapshotService {
if (StringUtils.isNotBlank(format) && value instanceof Date) {
value = DateUtil.format((Date) value, format.replaceAll("/", "-"));
}
// boolean 类型转换为String
if (value instanceof Boolean) {
value = String.valueOf(value);
}
}
valueMap.put(originKey, value == null ? "" : value);
}
/**
* 获取属性值
*
* @param list
* @param key
* @return
*/
private String getAttributeValue(List<CustomAttributes> list, AttributeEnum key) {
for (CustomAttributes customAttribute : list) {
if (AttributeEnum.LABELID.equals(key)) {
if (StringUtils.isNotBlank(customAttribute.getLabelId())) {
return customAttribute.getLabelId();
}
}
if (AttributeEnum.FIELDURL.equals(key)) {
if (StringUtils.isNotBlank(customAttribute.getFieldUrl())) {
return customAttribute.getFieldUrl();
}
}
if (AttributeEnum.CODETABLE.equals(key)) {
if (StringUtils.isNotBlank(customAttribute.getCodeTable())) {
return customAttribute.getCodeTable();
}
}
}
return "";
}
}
package com.brilliance.mda.runtime.mda.snapshot.bo;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/21
*/
public enum AttributeEnum {
LABELID("i18n"),
FIELDURL("fieldUrl"),
CODETABLE("codeTable");
private String value;
AttributeEnum(String value) {
this.value = value;
}
}
package com.brilliance.mda.runtime.mda.snapshot.bo.pack;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/21
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "checkbox")
@Data
public class PackCheckboxBo {
@XmlAttribute(name = "style")
private String style;
@XmlAttribute(name = "checked")
private String checked;
@XmlAttribute(name = "disabled")
private String disabled = "true";
@XmlAttribute(name = "label")
private String label;
@XmlAttribute(name = "zclass")
private String zclass = "z-checkbox";
}
......@@ -33,4 +33,7 @@ public class PackDivBo {
@XmlElement(name = "datebox")
private List<PackDateboxBo> dateboxBoList;
@XmlElement(name = "checkbox")
private List<PackCheckboxBo> checkboxBoList;
}
package com.brilliance.mda.runtime.mda.snapshot.bo.unpack;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/21
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "checkbox")
@Data
public class CheckboxBo {
@XmlAttribute(name = "style")
private String style;
@XmlElement(name = "custom-attributes")
private List<CustomAttributes> customAttributes;
}
......@@ -33,4 +33,7 @@ public class DivBo {
@XmlElement(name = "xdecimalbox")
private List<TextboxBo> xdecimalboxList;
@XmlElement(name = "checkbox")
private List<CheckboxBo> checkboxList;
}
......@@ -33,6 +33,9 @@ public class DocumentBo {
@XmlElement(name = "xdecimalbox")
private List<TextboxBo> xdecimalboxList;
@XmlElement(name = "checkbox")
private List<CheckboxBo> checkboxList;
@XmlElement(name = "borderlayout")
private BorderlayoutBo borderlayoutBo;
}
......@@ -3,6 +3,7 @@ package com.brilliance.mda.runtime.mda.snapshot.bo.unpack;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
/**
* @Description
......@@ -15,7 +16,7 @@ import javax.xml.bind.annotation.*;
public class LabelBo {
@XmlElement(name = "custom-attributes")
private CustomAttributes customAttributes;
private List<CustomAttributes> customAttributes;
@XmlAttribute(name = "style")
private String style;
......
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