From 55517e16da5e7205770bf61fc27c3d06b7d189b5 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 15 六月 2023 21:03:16 +0800
Subject: [PATCH] bug修改

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/util/ClientBusinessObject.java |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/util/ClientBusinessObject.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/util/ClientBusinessObject.java
new file mode 100644
index 0000000..0bbfd41
--- /dev/null
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/util/ClientBusinessObject.java
@@ -0,0 +1,110 @@
+package com.vci.ubcs.code.util;
+
+import com.vci.ubcs.code.bo.AttributeValue;
+import com.vci.ubcs.starter.exception.VciBaseException;
+import com.vci.ubcs.starter.revision.model.BaseModel;
+import lombok.Data;
+
+import java.util.ArrayList;
+
+@Data
+public class ClientBusinessObject extends BaseModel {
+
+	public AttributeValue[] newAttrValList;
+	public AttributeValue[] hisAttrValList;
+
+	public void setAttributeValue(String attributeName, String attributeValue) throws VciBaseException {
+		this.setAttributeValue(attributeName, attributeValue, false);
+	}
+
+	public void setAttributeValue(String attributeName, String attributeValue, boolean isCreate) throws VciBaseException {
+		int isValid = (new AttributeChecker()).isAttrValValid(attributeName, attributeValue);
+		if (isValid == 1) {
+			throw getLocalError("P0010SOF-00017", new String[]{attributeName, attributeValue});
+		} else if (isValid == 2) {
+			throw this.getLocalError("P0010SOF-00018", new String[]{attributeName, attributeValue});
+		} else if (isValid == 3) {
+			throw this.getLocalError("P0010SOF-00019", new String[]{attributeName, attributeValue});
+		} else {
+			this.setAttributeValueWithNoCheck(attributeName, attributeValue, isCreate);
+		}
+	}
+
+	public void setAttributeValueWithNoCheck(String attributeName, String attributeValue) throws VciBaseException {
+		this.setAttributeValueWithNoCheck(attributeName, attributeValue, false);
+	}
+
+	public void setAttributeValueWithNoCheck(String attributeName, String attributeValue, boolean isCreate) throws VciBaseException {
+		/*if (isCreate) {//&& BusinessConstants.BO_CONSTANTS.containsKey(attributeName.toUpperCase())
+			this.setConstantsAttrVal(attributeName, attributeValue);
+		} else {*/
+			AttributeValue[] attrValues = this.newAttrValList;
+			ArrayList<AttributeValue> attrValList = new ArrayList();
+			AttributeValue attrVal;
+			int i;
+			if (attrValues != null && attrValues.length > 0) {
+				AttributeValue[] var9 = attrValues;
+				i = attrValues.length;
+
+				for(int var7 = 0; var7 < i; ++var7) {
+					attrVal = var9[var7];
+					attrValList.add(attrVal);
+				}
+			}
+
+			attrVal = null;
+			boolean isExist = false;
+
+			for(i = 0; i < attrValList.size(); ++i) {
+				attrVal = (AttributeValue)attrValList.get(i);
+				if (attrVal.attrName.toUpperCase().equals(attributeName.toUpperCase())) {
+					attrVal.attrVal = attributeValue;
+					isExist = true;
+					break;
+				}
+			}
+
+			if (!isExist) {
+				attrVal = new AttributeValue();
+				attrVal.attrName = attributeName.toUpperCase();
+				attrVal.attrVal = attributeValue;
+				attrValList.add(attrVal);
+			}
+
+			this.newAttrValList = (AttributeValue[])attrValList.toArray(new AttributeValue[attrValList.size()]);
+	//	}
+	}
+
+	public String getAttributeValue(String attrName) {
+		String res = "";
+		boolean existInNewAttr = false;
+		int i;
+		if (this.newAttrValList != null) {
+			for(i = 0; i < this.newAttrValList.length; ++i) {
+				if (this.newAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
+					existInNewAttr = true;
+					res = this.newAttrValList[i].attrVal;
+				}
+			}
+		}
+
+		if (existInNewAttr) {
+			return res;
+		} else if (this.hisAttrValList == null) {
+			return "";
+		} else {
+			for(i = 0; i < this.hisAttrValList.length; ++i) {
+				if (this.hisAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
+					res = this.hisAttrValList[i].attrVal;
+				}
+			}
+
+			return res;
+		}
+	}
+
+	public VciBaseException getLocalError(String error_code ,String[] error_messages) {
+		return new VciBaseException(error_code, error_messages);
+	}
+
+}

--
Gitblit v1.9.3