管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-03 3cfb6aa02516135fb174ab1b30620f2007924663
JavaCode/FrmSys.cs
@@ -4,12 +4,10 @@
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace JavaCode
@@ -38,7 +36,7 @@
        private void btnReadTab_Click(object sender, EventArgs e)
        {
            string txtTab = this.txtTabPre.Text.Trim();
            string sql = "select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and c.relname like '" + txtTab + "%' and obj_description(c.oid) is not null and relnamespace=" + this.txtNS.Text.Trim() + " order by c.relname desc, a.attnum asc";
            string sql = "select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and c.relname like '" + txtTab + "%' and attname not like '%pg.dropped%' and obj_description(c.oid) is not null and relnamespace=" + this.txtTabNS.Text.Trim() + " order by c.relname desc, a.attnum asc";
            DataTable dt = _dbHelper.GetDataTable(sql, null);
@@ -96,7 +94,7 @@
        private void GenerateMapperXml(string name, List<TabInfo> tabs)
        {
            string tabName = this.txtTabNS.Text.Trim() + name;
            string tabName = this.txtTabPrefix.Text.Trim() + name;
            name = name.Replace(this.txtTabPre.Text, "");
            string shortName = NameConvert(name, true);
@@ -111,7 +109,8 @@
            string colType = GetJavaType(selectTabInfo);
            string colName = NameConvert(selectTabInfo.col, false);
            string testExpr = colName + " != null";
            string testWhere = selectTabInfo.col + (colType == "String" ? " like " : " = ") + "#{" + colName + "}";
            //string testWhere = selectTabInfo.col + (colType == "String" ? " like " : " = ") + "#{" + colName + "}";
            string testWhere = (colType == "String" ? "upper(" + selectTabInfo.col + ") like " : selectTabInfo.col + " = ") + "#{" + colName + "}";
            string insertCols = GetInsertCols(tabs);
            string insertVal = GetInsertVal(tabs);
@@ -359,7 +358,7 @@
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
            string colType  = GetJavaType(selectTabInfo);
            string colType = GetJavaType(selectTabInfo);
            string colName = NameConvert(selectTabInfo.col, false);
            string queryCol = colType + " " + colName;
            string colBak = selectTabInfo.bak;
@@ -539,6 +538,7 @@
            string entityName = shortName + "Entity";
            string serviceName = shortName + "Service";
            string bak = tabs[0].desc.Replace("表", "");
            string ns = this.txtNS.Text.Trim();
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
@@ -549,7 +549,7 @@
            //string where = isString ? "\r\n        " + colName + " = \"%\" + (StringHelper.isNull(" + colName + ") ? \"\" : " + colName + ".trim()) + \"%\";\r\n" : "";
            //string where = colType == "String" ? "\r\n        " + colName + " = StringHelper.isNull(" + colName + ") ? null : \"%\" + " + colName + ".trim() + \"%\";\r\n" : "";
            string where = colType == "String" ? "\r\n        " + colName + " = StringHelper.getLikeStr(" + colName + ");\r\n" : "";
            string where = colType == "String" ? "\r\n        " + colName + " = StringHelper.getLikeUpperStr(" + colName + ");\r\n" : "";
            string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Service.java"));
            xml = xml
@@ -563,7 +563,8 @@
                .Replace("{bak}", bak)
                .Replace("{queryCol}", queryCol)
                .Replace("{colName}", colName)
                .Replace("{where}", where);
                .Replace("{ns}", ns)
                .Replace("{where}", where);
            string path = Path.Combine(baseDir, "SysGenerate");
            if (!Directory.Exists(path))
@@ -612,6 +613,7 @@
            string controllerName = shortName + "Controller";
            string bak = tabs[0].desc.Replace("表", "");
            string apiName = NameConvert(name, false);
            string ns = this.txtNS.Text.Trim();
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
@@ -638,6 +640,7 @@
                .Replace("{colType}", colType)
                .Replace("{apiTag}", apiTag)
                .Replace("{apiName}", apiName)
                .Replace("{ns}", ns)
                .Replace("{bak}", bak);
            string path = Path.Combine(baseDir, "SysGenerate");
@@ -652,6 +655,15 @@
        #endregion
        #region 生成所有文件
        private void txtNS_TextChanged(object sender, EventArgs e)
        {
            string ns = txtNS.Text.Trim();
            txtMapperNS.Text = "com.lf.server.mapper.sys".Replace("lf", ns);
            txtEntityNS.Text = "com.lf.server.entity.sys".Replace("lf", ns);
            txtServiceNS.Text = "com.lf.server.service.sys".Replace("lf", ns);
            txtControllerNS.Text = "com.lf.server.controller.sys".Replace("lf", ns);
        }
        private void generateAll_Click(object sender, EventArgs e)
        {
            try