xf 3 mesi fa
parent
commit
08137391b9

+ 210 - 19
src/Hotline.Api/Controllers/KnowledgeController.cs

@@ -42,6 +42,9 @@ using XF.Utility.EnumExtensions;
 using System.Threading;
 using Hotline.Caching.Interfaces;
 using Hotline.Import;
+using Hotline.Caching.Services;
+using Hotline.Share.Enums.Order;
+using MiniExcelLibs;
 
 namespace Hotline.Api.Controllers
 {
@@ -806,23 +809,23 @@ namespace Hotline.Api.Controllers
         [HttpGet("knowledge-status-data")]
         public Dictionary<string, dynamic> KnowledgeStatus()
         {
-            //var tabNames = new List<KeyValuePair<int, string>>
-            //{
-            //    new KeyValuePair<int, string>(3, "已上架"),
-            //    new KeyValuePair<int, string>(4, "已下架"),
-            //    new KeyValuePair<int, string>(1, "审核中"),
-            //    new KeyValuePair<int, string>(8, "草稿"),
-            //    new KeyValuePair<int, string>(-1, "全部")
-            //};
-            var tabNames = EnumExts.GetDescriptions<EKnowledgeStatusRequest>();
-
-            //var tabNewDraftsNames = new List<KeyValuePair<int, string>>
-            //{
-            //    new KeyValuePair<int, string>(-1, "全部"),
-            //    new KeyValuePair<int, string>(0, "待提交"),
-            //    new KeyValuePair<int, string>(5, "审核不通过"),
-            //};
-            var tabNewDraftsNames = EnumExts.GetDescriptions<EKnowledgeDraftTypeRequest>();
+            var tabNames = new List<KeyValuePair<int, string>>
+            {
+                new KeyValuePair<int, string>(3, "已上架"),
+                new KeyValuePair<int, string>(4, "已下架"),
+                new KeyValuePair<int, string>(1, "审核中"),
+                new KeyValuePair<int, string>(8, "草稿"),
+                new KeyValuePair<int, string>(-1, "全部")
+            };
+            //var tabNames = EnumExts.GetDescriptions<EKnowledgeStatusRequest>();
+
+            var tabNewDraftsNames = new List<KeyValuePair<int, string>>
+            {
+                new KeyValuePair<int, string>(-1, "全部"),
+                new KeyValuePair<int, string>(0, "待提交"),
+                new KeyValuePair<int, string>(5, "审核不通过"),
+            };
+            //var tabNewDraftsNames = EnumExts.GetDescriptions<EKnowledgeDraftTypeRequest>();
 
 
             var tabAuditingNames = new List<KeyValuePair<string, string>>
@@ -958,8 +961,8 @@ namespace Hotline.Api.Controllers
         /// 下载知识导入模板
         /// </summary>
         /// <returns></returns>
-        [HttpGet("dl-kn-template")]
-        public async Task<object> DownLoadKnowledgeTemplate()
+        [HttpGet("dl-template")]
+        public object DownLoadKnowledgeTemplate()
         {
             return _exportApplication.ExportData(new List<KnowledgeImportTemplate>
             {
@@ -967,6 +970,194 @@ namespace Hotline.Api.Controllers
             }, "知识模板.xlsx");
         }
 
+        //[HttpPost("import-knowledge")]
+        //public async Task<object> ImportKnowledge(IFormFile file)
+        //{
+        //    using (var stream = new MemoryStream())
+        //    {
+        //        file.CopyTo(stream);
+        //        var list = MiniExcel.Query<KnowledgeImportTemplate>(stream).ToList();
+        //        int count = 0;
+        //        int errorCount = 0;
+        //        int addCount = 0;
+        //        int modifyCount = 0;
+        //        var allowSources = new Dictionary<string, string>
+        //    {
+        //        { "麻辣社区", "MLSQ" }, { "人民网", "RMW" }, { "省长信箱", "SZXX" }, { "问政四川", "WZSC" }
+        //    };
+        //        var errorMessage = new StringBuilder();
+        //        if (list == null || list.Count == 0)
+        //        {
+        //            return new { Count = count, ErrorCount = errorCount, AddCount = addCount, ModifyCount = modifyCount, ErrorMessage = "数据为空" };
+        //        }
+
+        //        count = list.Count;
+        //        var i = 0;
+        //        foreach (var item in list)
+        //        {
+        //            i++;
+        //            try
+        //            {
+        //                var validationResult = item.ValidateObject(false);
+        //                if (validationResult.NotNullOrEmpty())
+        //                {
+        //                    errorMessage.Append($"第{i + 1}行: {validationResult}\r\n");
+        //                    errorCount++;
+        //                    continue;
+        //                }
+
+        //                var allowSource = allowSources.FirstOrDefault(m => m.Key == item.Source).Value;
+        //                if (allowSource.IsNullOrEmpty())
+        //                {
+        //                    errorCount++;
+        //                    continue;
+        //                }
+
+        //                var SourceCode = (ESource)Enum.Parse(typeof(ESource), allowSource);
+        //                var acceptType = _sysDicDataCacheManager.AcceptType
+        //                    .FirstOrDefault(m => m.DicDataName == item.AcceptType);
+
+        //                if (acceptType == null)
+        //                {
+        //                    errorMessage.Append($"第{i + 1}行: 不能通过受理类型 {item.AcceptType} 查询到对应的受理类型Code\r\n");
+        //                    continue;
+        //                }
+
+        //                var order = await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == SourceCode,
+        //                    HttpContext.RequestAborted) ?? new Orders.Order();
+        //                item.Source = SourceCode.ToString();
+        //                order = _mapper.Map(item, order);
+        //                order.AcceptTypeCode = acceptType.DicDataValue;
+        //                order.SourceChannel = SourceCode.GetDescription();
+        //                order.SourceChannelCode = ((int)SourceCode).ToString();
+        //                order.Status = EOrderStatus.Visited;
+        //                #region 处理数据开始
+
+        //                // order.Source = SourceCode; //来源
+
+        //                //处理热点
+        //                //处理一级热点
+        //                string hotspotId = "";
+        //                string hotspotName = "";
+        //                string hotspotFullName = "";
+        //                var hotspotOne = await _hotspotTypeRepository.Queryable()
+        //                    .FirstAsync(x => x.HotSpotName == item.HotspotNameOne, HttpContext.RequestAborted);
+        //                if (hotspotOne != null)
+        //                {
+        //                    hotspotId = hotspotOne.Id;
+        //                    hotspotName = hotspotOne.HotSpotName;
+        //                    hotspotFullName = hotspotOne.HotSpotFullName;
+        //                    var hotspotTwo = await _hotspotTypeRepository.Queryable()
+        //                        .FirstAsync(x => x.HotSpotName == item.HotspotNameTwo && x.ParentId == hotspotId, HttpContext.RequestAborted);
+        //                    if (hotspotTwo != null)
+        //                    {
+        //                        hotspotId = hotspotTwo.Id;
+        //                        hotspotName = hotspotTwo.HotSpotName;
+        //                        hotspotFullName = hotspotTwo.HotSpotFullName;
+        //                        var hotspotThree = await _hotspotTypeRepository.Queryable()
+        //                            .FirstAsync(x => x.HotSpotName == item.HotspotNameThree && x.ParentId == hotspotId, HttpContext.RequestAborted);
+        //                        if (hotspotThree != null)
+        //                        {
+        //                            hotspotId = hotspotThree.Id;
+        //                            hotspotName = hotspotThree.HotSpotName;
+        //                            hotspotFullName = hotspotThree.HotSpotFullName;
+        //                            var hotspotFour = await _hotspotTypeRepository.Queryable()
+        //                                .FirstAsync(x => x.HotSpotName == item.HotspotNameFour && x.ParentId == hotspotId,
+        //                                    HttpContext.RequestAborted);
+        //                            if (hotspotFour != null)
+        //                            {
+        //                                hotspotId = hotspotFour.Id;
+        //                                hotspotName = hotspotFour.HotSpotName;
+        //                                hotspotFullName = hotspotFour.HotSpotFullName;
+        //                                var hotspotFive = await _hotspotTypeRepository.Queryable()
+        //                                    .FirstAsync(x => x.HotSpotName == item.HotspotNameFive && x.ParentId == hotspotId,
+        //                                        HttpContext.RequestAborted);
+        //                                if (hotspotFive != null)
+        //                                {
+        //                                    hotspotId = hotspotFive.Id;
+        //                                    hotspotName = hotspotFive.HotSpotName;
+        //                                    hotspotFullName = hotspotFive.HotSpotFullName;
+        //                                }
+        //                            }
+        //                        }
+        //                    }
+        //                }
+
+        //                order.HotspotId = hotspotId;
+        //                order.HotspotName = hotspotName;
+        //                order.HotspotSpliceName = hotspotFullName;
+
+        //                //处理部门
+        //                var orgOne = await _organizeRepository.Queryable()
+        //                    .FirstAsync(x => x.Name == item.OrgLevelOneName, HttpContext.RequestAborted);
+        //                if (orgOne != null)
+        //                {
+        //                    order.OrgLevelOneCode = orgOne.Id;
+        //                    order.OrgLevelOneName = orgOne.Name;
+        //                    var orgTwo = await _organizeRepository.Queryable()
+        //                        .FirstAsync(x => x.Name == item.OrgLevelTwoName && x.ParentId == order.OrgLevelOneCode, HttpContext.RequestAborted);
+        //                    if (orgTwo != null)
+        //                    {
+        //                        order.OrgLevelTwoCode = orgTwo.Id;
+        //                        order.OrgLevelTwoName = orgTwo.Name;
+        //                    }
+        //                }
+
+        //                //承办部门
+        //                var ActualHandleOrg = await _organizeRepository.Queryable()
+        //                    .FirstAsync(x => x.Name == item.ActualHandleOrgName, HttpContext.RequestAborted);
+        //                if (ActualHandleOrg != null)
+        //                {
+        //                    order.ActualHandleOrgCode = ActualHandleOrg.Id;
+        //                }
+
+        //                //处理地址
+        //                order.FullAddress = $"{order.Address}{order.Street}";
+
+        //                order.FirstVisitResultCode = _sysDicDataCacheManager
+        //                                                 .GetSysDicDataCache(SysDicTypeConsts.VisitSatisfaction)
+        //                                                 .FirstOrDefault(m => m.DicDataName == item.VisitResult)?.DicDataValue
+        //                                             ?? order.FirstVisitResultCode;
+
+        //                #endregion
+
+        //                if (order.Id.IsNullOrEmpty())
+        //                {
+        //                    //order.Source = item;
+        //                    var id = await _orderDomainService.AddAsync(order, false, HttpContext.RequestAborted);
+        //                    if (!string.IsNullOrEmpty(id))
+        //                    {
+        //                        addCount++;
+        //                    }
+        //                    else
+        //                    {
+        //                        errorCount++;
+        //                    }
+        //                }
+        //                else
+        //                {
+        //                    // _mapper.Map(item, order);
+        //                    await _orderRepository.UpdateAsync(order, HttpContext.RequestAborted);
+        //                    modifyCount++;
+        //                }
+        //            }
+        //            catch (Exception ex)
+        //            {
+        //                errorCount++;
+        //            }
+        //        }
+
+        //        return new
+        //        {
+        //            Count = count,
+        //            ErrorCount = errorCount,
+        //            AddCount = addCount,
+        //            ModifyCount = modifyCount,
+        //            ErrorMessage = errorMessage.ToString()
+        //        };
+        //    }
+        //}
+
         #endregion
 
         #region 我的知识删除列表

+ 1 - 1
src/Hotline.Application/ExportExcel/ExportApplication.cs

@@ -41,7 +41,7 @@ namespace Hotline.Application.ExportExcel
             stream.Seek(0, SeekOrigin.Begin);
             return new FileStreamResult(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
             {
-                FileDownloadName = !string.IsNullOrEmpty(name) ? DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx" : name
+                FileDownloadName = string.IsNullOrEmpty(name) ? DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx" : name
             };
         }
 

+ 98 - 0
src/Hotline.Share/Dtos/Knowledge/KnowPagedListDto.cs

@@ -0,0 +1,98 @@
+using Hotline.Share.Enums.KnowledgeBase;
+using Hotline.Share.Requests;
+
+namespace Hotline.Share.Dtos.Knowledge;
+
+public record KnowPagedListDto : PagedKeywordRequest
+{
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string? Title { get; set; }
+
+    /// <summary>
+    /// 状态
+    /// </summary>
+    public EKnowledgeStatusRequest Status { get; set; }
+
+    /// <summary>
+    /// 草稿状态下的查询条件
+    /// </summary>
+    public EKnowledgeDraftTypeRequest NewDraftsStatus { get; set; }
+
+    /// <summary>
+    /// 是否公开
+    /// </summary>
+    public bool? IsPublic { get; set; }
+
+    /// <summary>
+    /// 摘要
+    /// </summary>
+    public string? Summary { get; set; }
+
+    /// <summary>
+    /// 部门
+    /// </summary>
+    public string? CreateOrgId { get; set; }
+
+    /// <summary>
+    /// 热点
+    /// </summary>
+    public string? HotspotId { get; set; }
+
+    /// <summary>
+    /// 分类
+    /// </summary>
+    public string? KnowledgeTypeId { get; set; }
+
+    /// <summary>
+    /// 审批类型
+    /// </summary>
+    public string? ModuleCode { get; set; }
+
+    /// <summary>
+    ///   归属
+    /// </summary>
+    public string? Attribution { get; set; }
+
+    /// <summary>
+    /// 创建开始
+    /// </summary>
+    public DateTime? CreationStartTime { get; set; }
+
+    /// <summary>
+    /// 创建结束
+    /// </summary>
+    public DateTime? CreationEndTime { get; set; }
+
+    /// <summary>
+    /// 上架开始
+    /// </summary>
+    public DateTime? StartOnShelfTime { get; set; }
+
+    /// <summary>
+    /// 上架结束
+    /// </summary>
+    public DateTime? EndOnShelfTime { get; set; }
+
+    /// <summary>
+    /// 下架开始
+    /// </summary>
+    public DateTime? StartOffShelfTime { get; set; }
+
+    /// <summary>
+    /// 下架结束
+    /// </summary>
+    public DateTime? EndOffShelfTime { get; set; }
+
+    /// <summary>
+    /// 更新时间开始
+    /// </summary>
+    public DateTime? StartUpdateTime { get; set; }
+
+    /// <summary>
+    /// 更新时间结束
+    /// </summary>
+    public DateTime? EndUpdateTime { get; set; }
+
+}

+ 0 - 110
src/Hotline.Share/Dtos/Knowledge/KnowledgePagedDto.cs

@@ -89,114 +89,4 @@ namespace Hotline.Share.Dtos.Knowledge
     /// <param name="StartApplyTime"></param>
     /// <param name="EndApplyTime"></param>
     public record KnowledgeDeletelPagedListDto(EKnowledgeWorkFlowStatus? EKnowledgeWorkFlowStatus, DateTime? StartApplyTime, DateTime? EndApplyTime) : PagedKeywordRequest;
-
-    /// <summary>
-    /// 
-    /// </summary>
-    /// <param name="CreateOrgId">部门</param>
-    /// <param name="HotspotId">热点</param>
-    /// <param name="KnowledgeTypeId">分类</param>
-    /// <param name="Status">状态</param>
-    /// <param name="CreationStartTime">创建开始</param>
-    /// <param name="CreationEndTime">创建结束</param>
-    /// <param name="StartOnShelfTime">上架时间-开始</param>
-    /// <param name="EndOnShelfTime">上架时间-结束</param>
-    /// <param name="StartOffShelfTime">下架时间-开始</param>
-    /// <param name="EndOffShelfTime">下架时间-结束</param>
-    //public record KnowPagedListDto(string? CreateOrgId, string? HotspotId, string? KnowledgeTypeId, EKnowledgeStatus? Status, DateTime? CreationStartTime, DateTime? CreationEndTime,
-    //  DateTime? StartOnShelfTime, DateTime? EndOnShelfTime, DateTime? StartOffShelfTime, DateTime? EndOffShelfTime) : PagedKeywordRequest;
-
-    public record KnowPagedListDto : PagedKeywordRequest
-    {
-        /// <summary>
-        /// 标题
-        /// </summary>
-        public string? Title { get; set; }
-
-        /// <summary>
-        /// 状态
-        /// </summary>
-        public EKnowledgeStatusRequest Status { get; set; }
-
-        /// <summary>
-        /// 草稿状态下的查询条件
-        /// </summary>
-        public EKnowledgeDraftTypeRequest NewDraftsStatus { get; set; }
-
-        /// <summary>
-        /// 是否公开
-        /// </summary>
-        public bool? IsPublic { get; set; }
-
-        /// <summary>
-        /// 摘要
-        /// </summary>
-        public string? Summary { get; set; }
-
-        /// <summary>
-        /// 部门
-        /// </summary>
-        public string? CreateOrgId { get; set; }
-
-        /// <summary>
-        /// 热点
-        /// </summary>
-        public string? HotspotId { get; set; }
-
-        /// <summary>
-        /// 分类
-        /// </summary>
-        public string? KnowledgeTypeId { get; set; }
-
-        /// <summary>
-        /// 审批类型
-        /// </summary>
-        public string? ModuleCode { get; set; }
-
-        /// <summary>
-        ///   归属
-        /// </summary>
-        public string? Attribution { get; set; }
-
-        /// <summary>
-        /// 创建开始
-        /// </summary>
-        public DateTime? CreationStartTime { get; set; }
-
-        /// <summary>
-        /// 创建结束
-        /// </summary>
-        public DateTime? CreationEndTime { get; set; }
-
-        /// <summary>
-        /// 上架开始
-        /// </summary>
-        public DateTime? StartOnShelfTime { get; set; }
-
-        /// <summary>
-        /// 上架结束
-        /// </summary>
-        public DateTime? EndOnShelfTime { get; set; }
-
-        /// <summary>
-        /// 下架开始
-        /// </summary>
-        public DateTime? StartOffShelfTime { get; set; }
-
-        /// <summary>
-        /// 下架结束
-        /// </summary>
-        public DateTime? EndOffShelfTime { get; set; }
-
-        /// <summary>
-        /// 更新时间开始
-        /// </summary>
-        public DateTime? StartUpdateTime { get; set; }
-
-        /// <summary>
-        /// 更新时间结束
-        /// </summary>
-        public DateTime? EndUpdateTime { get; set; }
-
-    }
 }

+ 1 - 1
src/Hotline.Share/Enums/KnowledgeBase/EKnowledgeStatus.cs

@@ -95,7 +95,7 @@ public enum EKnowledgeStatusRequest
     /// 待提交
     /// </summary>
     [Description("草稿")]
-    Drafts = 0,
+    Drafts = 8,
 
     /// <summary>
     /// 全部