| | |
| | | using Microsoft.EntityFrameworkCore.Infrastructure; |
| | | using Microsoft.EntityFrameworkCore.Metadata; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.Drawing; |
| | | using OfficeOpenXml; |
| | | using System; |
| | | using StackExchange.Profiling.Internal; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Web; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using OfficeOpenXml.Style; |
| | | using System.Net.WebSockets; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using Microsoft.EntityFrameworkCore.Metadata.Internal; |
| | | using System.Reflection; |
| | | using NetTopologySuite.Noding; |
| | | using System.Xml.Linq; |
| | | using static Npgsql.Replication.PgOutput.Messages.RelationMessage; |
| | | using StackExchange.Profiling.Internal; |
| | | using System.Collections.Generic; |
| | | using System.Data.SqlTypes; |
| | | |
| | | namespace Admin.NET.Application.CodeGen |
| | | { |
| | |
| | | private readonly IRepository<SysLowCode> _sysLowCodeRep; // 代码生成器仓储 |
| | | private readonly ICodeGenConfigService _codeGenConfigService; |
| | | private readonly IViewEngine _viewEngine; |
| | | private readonly ISysExcelTemplateService _sysExcelTemplateService; |
| | | private readonly ISysEnumDataService _sysEnumDataService; |
| | | private readonly IRepository<SysMenu> _sysMenuRep; // 菜单表仓储 |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="codeGenConfigService"></param> |
| | | /// <param name="viewEngine"></param> |
| | | /// <param name="sysMenuRep"></param> |
| | | /// <param name="sysEnumDataService"></param> |
| | | public CodeGenerateService(IRepository<SysCodeGen> sysCodeGenRep, |
| | | IRepository<SysLowCode> sysLowCodeRep, |
| | | ICodeGenConfigService codeGenConfigService, |
| | | IViewEngine viewEngine, |
| | | IRepository<SysMenu> sysMenuRep, |
| | | ISysExcelTemplateService sysExcelTemplateService) |
| | | ISysEnumDataService sysEnumDataService) |
| | | { |
| | | _sysCodeGenRep = sysCodeGenRep; |
| | | _sysLowCodeRep = sysLowCodeRep; |
| | | _codeGenConfigService = codeGenConfigService; |
| | | _viewEngine = viewEngine; |
| | | _sysMenuRep = sysMenuRep; |
| | | _sysExcelTemplateService = sysExcelTemplateService; |
| | | _sysEnumDataService = sysEnumDataService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | //获取要处理的代码生成配置的是增改的模版字段 |
| | | var showCodeGenConfigs = tableFieldList.Where(w => w.WhetherAddUpdate.Equals("Y")).ToList(); |
| | | showCodeGenConfigs = showCodeGenConfigs.Where(x => x.ColumnKey.ToLower() == "false").ToList(); |
| | | int _mergeCellsCount = showCodeGenConfigs.Count();//合并列(模版赋值的标题列数) |
| | | //获取必填字段 |
| | | |
| | |
| | | StringBuilder _remarkContentBuilder = new StringBuilder(); |
| | | _remarkContentBuilder.AppendLine(""); |
| | | _remarkContentBuilder.AppendLine("1.支持Excel2007及以上版本文件。"); |
| | | _remarkContentBuilder.AppendLine("2.导入新增数据时不能超过5000行。"); |
| | | _remarkContentBuilder.AppendLine("3.导入更新数据时不能超过2000行。"); |
| | | _remarkContentBuilder.AppendLine("2.导入数据时不能超过5000行。"); |
| | | _remarkContentBuilder.AppendLine(""); |
| | | _remarkContentBuilder.AppendLine(""); |
| | | |
| | | Dictionary<string, string> typeNameDict = new() |
| | | { |
| | | { "string", "文本。"}, |
| | | { "int", "数字。"}, |
| | | { "long", "数字。"}, |
| | | { "decimal", "小数。"}, |
| | | { "bool", "布尔。示例:是、否。"}, |
| | | { "string", "输入文本。"}, |
| | | { "int", "输入数字。"}, |
| | | { "long", "输入数字。"}, |
| | | { "decimal", "输入小数。"}, |
| | | { "bool", "是,否。"}, |
| | | |
| | | }; |
| | | Dictionary<string, string> effectTypeDict = new() |
| | | { |
| | | { "datepicker", "日期。 示例: 2023/3/1"}, |
| | | { "datetimepicker", "日期时间。示例: 2023/3/1 12:00:00"}, |
| | | { "datepicker", "日期。 示例: 2023/3/1。"}, |
| | | { "datetimepicker", "日期时间。示例: 2023/3/1 12:00:00。"}, |
| | | |
| | | }; |
| | | |
| | | requiredTableFieldList.ForEach(x => |
| | | { |
| | | string text = ""; |
| | |
| | | { |
| | | text += typeNameDict[x.DtoNetType]; |
| | | } |
| | | else if (x.EffectType == "select") |
| | | { |
| | | var queryValue = x.DtoNetType.Split('.').Last(); |
| | | var enumStr = _sysEnumDataService.GetEnumDataListStr(new EnumDataInput() { EnumName = queryValue }); |
| | | text += enumStr + "。"; |
| | | } |
| | | else |
| | | { |
| | | text += ("注意:类型未能识别出来,需要自己维护!!!。"); |