From f9a3ac34d690aafc96757370e1f6f948ad98368d Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 22 九月 2025 17:28:12 +0800
Subject: [PATCH] yys 1.回款登记台账页面,增加一个开票日期列 2.销售台账,在合同金额后面,增加已开票金额、待开票金额、已回款金额、待回款金额
---
src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java | 139 +++++++++++++++++++++++++++++++++++++---------
1 files changed, 111 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java
index 675cd6c..ba1b06d 100644
--- a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java
+++ b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java
@@ -3,8 +3,10 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.velocity.VelocityContext;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
@@ -29,7 +31,7 @@
/**
* 璁剧疆妯℃澘鍙橀噺淇℃伅
- *
+ *
* @return 妯℃澘鍒楄〃
*/
public static VelocityContext prepareContext(GenTable genTable)
@@ -54,14 +56,19 @@
velocityContext.put("author", genTable.getFunctionAuthor());
velocityContext.put("datetime", DateUtils.getDate());
velocityContext.put("pkColumn", genTable.getPkColumn());
- velocityContext.put("importList", getImportList(genTable.getColumns()));
+ velocityContext.put("importList", getImportList(genTable));
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
velocityContext.put("columns", genTable.getColumns());
velocityContext.put("table", genTable);
+ velocityContext.put("dicts", getDicts(genTable));
setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory))
{
setTreeVelocityContext(velocityContext, genTable);
+ }
+ if (GenConstants.TPL_SUB.equals(tplCategory))
+ {
+ setSubVelocityContext(velocityContext, genTable);
}
return velocityContext;
}
@@ -69,7 +76,7 @@
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId);
}
@@ -77,7 +84,7 @@
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String treeCode = getTreecode(paramsObj);
String treeParentCode = getTreeParentCode(paramsObj);
String treeName = getTreeName(paramsObj);
@@ -96,13 +103,37 @@
}
}
+ public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
+ {
+ GenTable subTable = genTable.getSubTable();
+ String subTableName = genTable.getSubTableName();
+ String subTableFkName = genTable.getSubTableFkName();
+ String subClassName = genTable.getSubTable().getClassName();
+ String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
+
+ context.put("subTable", subTable);
+ context.put("subTableName", subTableName);
+ context.put("subTableFkName", subTableFkName);
+ context.put("subTableFkClassName", subTableFkClassName);
+ context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
+ context.put("subClassName", subClassName);
+ context.put("subclassName", StringUtils.uncapitalize(subClassName));
+ context.put("subImportList", getImportList(genTable.getSubTable()));
+ }
+
/**
* 鑾峰彇妯℃澘淇℃伅
- *
+ * @param tplCategory 鐢熸垚鐨勬ā鏉�
+ * @param tplWebType 鍓嶇绫诲瀷
* @return 妯℃澘鍒楄〃
*/
- public static List<String> getTemplateList(String tplCategory)
+ public static List<String> getTemplateList(String tplCategory, String tplWebType)
{
+ String useWebType = "vm/vue";
+ if ("element-plus".equals(tplWebType))
+ {
+ useWebType = "vm/vue/v3";
+ }
List<String> templates = new ArrayList<String>();
templates.add("vm/java/domain.java.vm");
templates.add("vm/java/mapper.java.vm");
@@ -114,11 +145,16 @@
templates.add("vm/js/api.js.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
- templates.add("vm/vue/index.vue.vm");
+ templates.add(useWebType + "/index.vue.vm");
}
else if (GenConstants.TPL_TREE.equals(tplCategory))
{
- templates.add("vm/vue/index-tree.vue.vm");
+ templates.add(useWebType + "/index-tree.vue.vm");
+ }
+ else if (GenConstants.TPL_SUB.equals(tplCategory))
+ {
+ templates.add(useWebType + "/index.vue.vm");
+ templates.add("vm/java/sub-domain.java.vm");
}
return templates;
}
@@ -146,6 +182,10 @@
if (template.contains("domain.java.vm"))
{
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
+ }
+ if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
+ {
+ fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
}
else if (template.contains("mapper.java.vm"))
{
@@ -188,26 +228,31 @@
/**
* 鑾峰彇鍖呭墠缂�
- *
+ *
* @param packageName 鍖呭悕绉�
* @return 鍖呭墠缂�鍚嶇О
*/
public static String getPackagePrefix(String packageName)
{
int lastIndex = packageName.lastIndexOf(".");
- String basePackage = StringUtils.substring(packageName, 0, lastIndex);
- return basePackage;
+ return StringUtils.substring(packageName, 0, lastIndex);
}
/**
* 鏍规嵁鍒楃被鍨嬭幏鍙栧鍏ュ寘
*
- * @param column 鍒楅泦鍚�
+ * @param genTable 涓氬姟琛ㄥ璞�
* @return 杩斿洖闇�瑕佸鍏ョ殑鍖呭垪琛�
*/
- public static HashSet<String> getImportList(List<GenTableColumn> columns)
+ public static HashSet<String> getImportList(GenTable genTable)
{
+ List<GenTableColumn> columns = genTable.getColumns();
+ GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>();
+ if (StringUtils.isNotNull(subGenTable))
+ {
+ importList.add("java.util.List");
+ }
for (GenTableColumn column : columns)
{
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
@@ -224,8 +269,46 @@
}
/**
- * 鑾峰彇鏉冮檺鍓嶇紑
+ * 鏍规嵁鍒楃被鍨嬭幏鍙栧瓧鍏哥粍
*
+ * @param genTable 涓氬姟琛ㄥ璞�
+ * @return 杩斿洖瀛楀吀缁�
+ */
+ public static String getDicts(GenTable genTable)
+ {
+ List<GenTableColumn> columns = genTable.getColumns();
+ Set<String> dicts = new HashSet<String>();
+ addDicts(dicts, columns);
+ if (StringUtils.isNotNull(genTable.getSubTable()))
+ {
+ List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
+ addDicts(dicts, subColumns);
+ }
+ return StringUtils.join(dicts, ", ");
+ }
+
+ /**
+ * 娣诲姞瀛楀吀鍒楄〃
+ *
+ * @param dicts 瀛楀吀鍒楄〃
+ * @param columns 鍒楅泦鍚�
+ */
+ public static void addDicts(Set<String> dicts, List<GenTableColumn> columns)
+ {
+ for (GenTableColumn column : columns)
+ {
+ if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
+ column.getHtmlType(),
+ new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX }))
+ {
+ dicts.add("'" + column.getDictType() + "'");
+ }
+ }
+ }
+
+ /**
+ * 鑾峰彇鏉冮檺鍓嶇紑
+ *
* @param moduleName 妯″潡鍚嶇О
* @param businessName 涓氬姟鍚嶇О
* @return 杩斿洖鏉冮檺鍓嶇紑
@@ -233,18 +316,18 @@
public static String getPermissionPrefix(String moduleName, String businessName)
{
return StringUtils.format("{}:{}", moduleName, businessName);
-
}
/**
* 鑾峰彇涓婄骇鑿滃崟ID瀛楁
- *
- * @param options 鐢熸垚鍏朵粬閫夐」
+ *
+ * @param paramsObj 鐢熸垚鍏朵粬閫夐」
* @return 涓婄骇鑿滃崟ID瀛楁
*/
public static String getParentMenuId(JSONObject paramsObj)
{
- if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
+ if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
+ && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID)))
{
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
}
@@ -253,8 +336,8 @@
/**
* 鑾峰彇鏍戠紪鐮�
- *
- * @param options 鐢熸垚鍏朵粬閫夐」
+ *
+ * @param paramsObj 鐢熸垚鍏朵粬閫夐」
* @return 鏍戠紪鐮�
*/
public static String getTreecode(JSONObject paramsObj)
@@ -268,8 +351,8 @@
/**
* 鑾峰彇鏍戠埗缂栫爜
- *
- * @param options 鐢熸垚鍏朵粬閫夐」
+ *
+ * @param paramsObj 鐢熸垚鍏朵粬閫夐」
* @return 鏍戠埗缂栫爜
*/
public static String getTreeParentCode(JSONObject paramsObj)
@@ -283,8 +366,8 @@
/**
* 鑾峰彇鏍戝悕绉�
- *
- * @param options 鐢熸垚鍏朵粬閫夐」
+ *
+ * @param paramsObj 鐢熸垚鍏朵粬閫夐」
* @return 鏍戝悕绉�
*/
public static String getTreeName(JSONObject paramsObj)
@@ -298,14 +381,14 @@
/**
* 鑾峰彇闇�瑕佸湪鍝竴鍒椾笂闈㈡樉绀哄睍寮�鎸夐挳
- *
+ *
* @param genTable 涓氬姟琛ㄥ璞�
* @return 灞曞紑鎸夐挳鍒楀簭鍙�
*/
public static int getExpandColumn(GenTable genTable)
{
String options = genTable.getOptions();
- JSONObject paramsObj = JSONObject.parseObject(options);
+ JSONObject paramsObj = JSON.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
int num = 0;
for (GenTableColumn column : genTable.getColumns())
@@ -322,4 +405,4 @@
}
return num;
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3