From fab8208b83a3c710cdfc3805655f04f0b7466be5 Mon Sep 17 00:00:00 2001
From: xiejun <xiejun@vci-tech.com>
Date: 星期三, 08 一月 2025 11:26:00 +0800
Subject: [PATCH] 产品型号集成,类型转换,人员组织加日志,申请接口引用码段值校验

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java |   83 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java
index 8d26247..0708de7 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java
@@ -56,6 +56,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ForkJoinPool;
@@ -158,6 +161,7 @@
 				// webservice璇锋眰鏂瑰紡鑾峰彇HttpServletRequest瀵硅薄
 				request = (HttpServletRequest)webServiceContext.getMessageContext().get(MessageContext.SERVLET_REQUEST);
 			}catch (Exception e){
+				e.printStackTrace();
 				log.error("鑾峰彇httpServletRequest澶辫触锛屽師鍥�:***********:",e);
 				throw new ServiceException("鑾峰彇httpServletRequest澶辫触锛屽師鍥�:"+e.getMessage());
 			}
@@ -174,7 +178,7 @@
 		List<ResultMdMapping> resultMdMappingList=new ArrayList<>();
 		String message="";
 		AtomicBoolean success = new AtomicBoolean(true);
-		List<Map<String,String>> masterDataList = new ArrayList<>();
+		List<Map<String,Object>> masterDataList = new ArrayList<>();
 		AtomicReference<ClassifyConfig> currentClassifyConfig = new AtomicReference<>(new ClassifyConfig());
 		try {
 			if (mdmParamData == null) {
@@ -214,12 +218,14 @@
 				});
 				masterDataList.stream().forEach(masterData -> {
 						masterData.forEach((field, vaule) -> {
+							String newValue="";
 							if (fieldClassifyConfigMap.containsKey(field)) {
-								vaule=StringUtils.isBlank(vaule) ? "" : vaule;
+								//vaule=StringUtils.isBlank(vaule) ? "" : vaule;
+								newValue=objectToStr(vaule);
 								List<ClassifyConfig> classifyConfigs = fieldClassifyConfigMap.get(field);
 								Map<String, ClassifyConfig> classifyConfigMap = classifyConfigs.stream().filter(classify -> classify != null && StringUtils.isNotBlank(classify.getSourceClassifyCode())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getSourceClassifyCode(), t -> t));
-								if (classifyConfigMap.containsKey(vaule)) {
-									currentClassifyConfig.set(classifyConfigMap.get(vaule));
+								if (classifyConfigMap.containsKey(newValue)) {
+									currentClassifyConfig.set(classifyConfigMap.get(newValue));
 								}
 							}
 						});
@@ -283,8 +289,9 @@
 					/***
 					 * 鏍规嵁閰嶇疆鏂囦欢鑾峰彇鏋氫妇鍊�
 					 */
+					String newValue=objectToStr(vaule);
 					if(fields.contains(field)){//濡傛灉鏄灇涓撅紝鍒欓渶瑕佽浆鎹㈡灇涓惧��
-						String enumFiled = masterData.get(field);
+						String enumFiled = newValue;
 						EnumerableData enumerableData = JSONObject.toJavaObject(JSONObject.parseObject(enumFiled), EnumerableData.class);
 						String enumCode = enumerableData.getCode();
 						//String enumCodeValue=enumerableData.getName();
@@ -295,7 +302,7 @@
 					}else {
 						ProppertyVO proppertyVO = new ProppertyVO();
 						proppertyVO.setKey(field);
-						proppertyVO.setValue(vaule);
+						proppertyVO.setValue(newValue);
 						proppertyVOList.add(proppertyVO);
 					}
 
@@ -435,6 +442,7 @@
 									});
 								}catch (Throwable e){
 									mesg="璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�:"+e.getMessage();
+									e.printStackTrace();
 									log.error("璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�,鍘熷洜:***********:",e);
 									new Throwable("璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�:"+e.getMessage());
 								}
@@ -593,6 +601,7 @@
 		}catch (Throwable e){
 			objerrorCode="100";
 			log.error("鑾峰彇鍒嗙被淇℃伅澶辫触:",e);
+			e.printStackTrace();
 			throw 	new  Throwable("鑾峰彇鍒嗙被淇℃伅澶辫触:"+e.getMessage());
 		}
 		return classifyVO;
@@ -821,4 +830,66 @@
 		dockingLogeService.save(dockingLoge);
 		log.info("闆嗘垚鎺ㄩ�佹暟鎹�,systemId:"+systemId+",systemname:"+systemName+",operation:"+operation+",param:"+parmaData);
 	}
+
+	/***
+	 * 灞炴�х被鍨嬭浆鎹�
+	 * @param vaule
+	 * @return
+	 */
+	private  String objectToStr(Object vaule) {
+		String newValue="";
+		if(vaule ==null||"".equals(vaule)||vaule==""){
+			return "";
+		}
+		try {
+			if (vaule instanceof Integer) {
+				Integer intValue = (Integer) vaule;
+				newValue = String.valueOf(intValue);
+			} else if (vaule instanceof Boolean) {
+				boolean boolValue = (Boolean) vaule;
+				newValue = Boolean.toString(boolValue);
+			} else if (vaule instanceof Timestamp) {
+				Timestamp timestampValue = (Timestamp) vaule;
+				newValue = timestamp2Str(timestampValue);
+			} else if (vaule instanceof Date) {
+				Date dataValue = (Date) vaule;
+				newValue = date2Str(dataValue, "yyyy-MM-dd HH:mm:ss");
+			}else if (vaule instanceof BigDecimal){
+				BigDecimal bigDecimal=(BigDecimal)vaule;
+				newValue =  bigDecimal.toString();
+			} else {
+				return vaule.toString();
+			}
+		}catch (Throwable e){
+			//	log.error("灞炴�х被鍨嬭浆鎹㈤敊璇�",e);
+			e.printStackTrace();
+		}
+		return newValue;
+	}
+
+	private String date2Str(Date date, String format) {
+		if (null == date) {
+			return null;
+		} else {
+			if (format == null || format.trim().length() == 0) {
+				format = "yyyy-MM-dd HH:mm:ss.SSS";
+			}
+
+			SimpleDateFormat sdf = new SimpleDateFormat(format);
+			return sdf.format(date);
+		}
+	}
+
+	private  String timestamp2Str(Timestamp time) {
+		Date date = null;
+		if (null == time) {
+			return null;
+		} else {
+			if (null != time) {
+				date = new Date(time.getTime());
+			}
+
+			return date2Str(date, "yyyy-MM-dd HH:mm:ss.SSS");
+		}
+	}
 }

--
Gitblit v1.9.3