From f2e6e77dc5a984e2fec4416717baa7c47118fcb1 Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期五, 14 四月 2023 17:26:58 +0800 Subject: [PATCH] 主题库相关的代码实现功能,包括excel导入导出,树形查看等功能 --- Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java index bc3a1ff..58336f4 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.vci.ubcs.com.vci.starter.exception.VciBaseException; import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo; +import com.vci.ubcs.com.vci.starter.web.toolmodel.DateConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; @@ -1142,6 +1143,69 @@ return listHasList; } } + public static short getShort(String s) { +// short i = false; + if (s == null) { + return 0; + } else { + try { + short i = Short.parseShort(s); + return i; + } catch (Exception var3) { + return 0; + } + } + } + + public static void setValueForField(Field field, Object obj, String value) { + try { + if (field != null && StringUtils.isNotBlank(value)) { + field.setAccessible(true); + Method setMethod = getSetmethod(field.getDeclaringClass(), field.getName()); + Class type = field.getType(); + Object valueObj = null; + if (!type.equals(Integer.TYPE) && !type.equals(Integer.class)) { + if (!type.equals(Float.TYPE) && !type.equals(Float.class)) { + if (!type.equals(Long.TYPE) && !type.equals(Long.class)) { + if (!type.equals(Double.class) && !type.equals(Double.TYPE)) { + if (type.equals(Date.class)) { + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(value); + valueObj = dateConverter.getValue(); + } else if (type.equals(String.class)) { + valueObj = value; + } else { + valueObj = value; + if (log.isErrorEnabled()) { + log.error("涓嶆敮鎸佺殑绫诲瀷" + type.toString()); + } + } + } else { + valueObj = getDouble(value); + } + } else { + valueObj = getLong(value); + } + } else { + valueObj = getFloat(value); + } + } else { + valueObj = getInt(value); + } + + if (setMethod != null) { + setMethod.invoke(obj, valueObj); + } else { + field.set(obj, valueObj); + } + } + } catch (Throwable var7) { + if (log.isErrorEnabled()) { + log.error("璁剧疆灞炴�х殑鍊煎嚭閿欎簡閿欒", var7); + } + } + + } } -- Gitblit v1.9.3