Commit d8b7458b by s_guodong

checkbox处理

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