Browse Source

orderimport

Dun.Jason 10 months ago
parent
commit
dab629ce5d

+ 98 - 2
src/Hotline.Api/Controllers/OrderController.cs

@@ -45,9 +45,12 @@ using MediatR;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using MiniExcelLibs;
 using MiniExcelLibs;
+using NPOI.SS.Formula.Functions;
+using NPOI.SS.Util;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities;
 using SqlSugar;
 using SqlSugar;
 using StackExchange.Redis;
 using StackExchange.Redis;
+using System.Diagnostics.Tracing;
 using XF.Domain.Authentications;
 using XF.Domain.Authentications;
 using XF.Domain.Cache;
 using XF.Domain.Cache;
 using XF.Domain.Constants;
 using XF.Domain.Constants;
@@ -4766,15 +4769,108 @@ public class OrderController : BaseController
                 {
                 {
                     try
                     try
                     {
                     {
-                        if (item.Source < ESource.MLSQ || item.Source > ESource.WZSC)
+
+                        if(item.Source!= "麻辣社区"|| item.Source!= "人民网" || item.Source!= "省长信箱" || item.Source!= "问政四川")
+                        //if (item.Source < ESource.MLSQ || item.Source > ESource.WZSC)
                         {
                         {
                             errorCount++;
                             errorCount++;
                             continue;
                             continue;
                         }
                         }
-                        var order = await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == item.Source, HttpContext.RequestAborted);
+                        int SourceCode = 0;
+
+                        switch (item.Source)
+                        {
+                            case "麻辣社区":
+                                SourceCode = 500;
+                                break;
+                            case "人民网":
+                                SourceCode = 501;
+                                break;
+                            case "省长信箱":
+                                SourceCode = 502;
+                                break;
+                            case "问政四川":
+                                SourceCode = 529;
+                                break;
+                            default:
+                                break;
+                        }
+                        var order = await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == (ESource)SourceCode, HttpContext.RequestAborted);
                         if (order is null)
                         if (order is null)
                         {
                         {
                             order = _mapper.Map<Orders.Order>(item);
                             order = _mapper.Map<Orders.Order>(item);
+                            #region 处理数据开始
+                            order.Source = (ESource)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.Address = $"{order.Province}{order.City}{order.County}{order.Town}";
+                            order.FullAddress = $"{order.Address}{order.Street}";
+
+                            #endregion
                             //order.Source = item;
                             //order.Source = item;
                             var id = await _orderRepository.AddAsync(order, HttpContext.RequestAborted);
                             var id = await _orderRepository.AddAsync(order, HttpContext.RequestAborted);
                             if (!string.IsNullOrEmpty(id))
                             if (!string.IsNullOrEmpty(id))

+ 48 - 44
src/Hotline/Import/ExcelContent.cs

@@ -1,49 +1,56 @@
 using Hotline.Share.Enums.Order;
 using Hotline.Share.Enums.Order;
 using MiniExcelLibs.Attributes;
 using MiniExcelLibs.Attributes;
+using SqlSugar;
 
 
 
 
 namespace Hotline.Import
 namespace Hotline.Import
 {
 {
     public class ExcelContent
     public class ExcelContent
     {
     {
+        [ExcelColumnName("来源")]
+        public string Source { get; set; }
+
         [ExcelColumnName("编号")]
         [ExcelColumnName("编号")]
         public string ExternalId { get; set; }
         public string ExternalId { get; set; }
 
 
-        [ExcelColumnName("标题")]
-        public string Title { get; set; }
-
         [ExcelColumnName("受理时间")]
         [ExcelColumnName("受理时间")]
         public DateTime StartTime { get; set; }
         public DateTime StartTime { get; set; }
 
 
-        [ExcelColumnName("内容")]
-        public string Content { get; set; }
-
-        [ExcelColumnName("受理类型编号(字典值)")]
-        public string AcceptTypeCode { get; set; }
+        [ExcelColumnName("标题")]
+        public string Title { get; set; }
 
 
+        [ExcelColumnName("期满时间")]
+        public DateTime ExpiredTime { get; set; }
+        /// <summary>
+        /// 一级部门名称
+        /// </summary>
+        [ExcelColumnName("一级部门")]
+        public string? OrgLevelOneName { get; set; }
+        /// <summary>
+        /// 二级部门名称
+        /// </summary>
+        [ExcelColumnName("二级部门")]
+        public string? OrgLevelTwoName { get; set; }
+
+        [ExcelColumnName("承办部门")]
+        public string ActualHandleOrgName { get; set; }
+        [ExcelColumnName("办结时间")]
+        public DateTime ActualHandleTime { get; set; }
         [ExcelColumnName("受理类型")]
         [ExcelColumnName("受理类型")]
         public string AcceptType { get; set; }
         public string AcceptType { get; set; }
+        [ExcelColumnName("一级热点")]
+        public string HotspotNameOne { get; set; }
 
 
-        [ExcelColumnName("热点全称")]
-        public string HotspotSpliceName { get; set; }
-
-        [ExcelColumnName("热点名称")]
-        public string HotspotName { get; set; }
+        [ExcelColumnName("二级热点")]
+        public string HotspotNameTwo { get; set; }
+        [ExcelColumnName("三级热点")]
+        public string HotspotNameThree { get; set; }
 
 
-        [ExcelColumnName("热点编码")]
-        public string HotspotId { get; set; }
+        [ExcelColumnName("四级热点")]
+        public string HotspotNameFour { get; set;}
 
 
-        [ExcelColumnName("事件全称")]
-        public string EventCategorySpliceName { get; set; }
-
-        [ExcelColumnName("事件名称")]
-        public string EventCategoryName { get; set; }
-
-        [ExcelColumnName("事件编码")]
-        public string EventCategoryId { get; set; }
-
-        [ExcelColumnName("地址编码")]
-        public string AreaCode { get; set; }
+        [ExcelColumnName("五级热点")]
+        public string HotspotNameFive { get; set; }
 
 
         [ExcelColumnName("市")]
         [ExcelColumnName("市")]
         public string City { get; set; }
         public string City { get; set; }
@@ -51,31 +58,28 @@ namespace Hotline.Import
         [ExcelColumnName("区")]
         [ExcelColumnName("区")]
         public string County { get; set; }
         public string County { get; set; }
 
 
-        [ExcelColumnName("详细地址")]
-        public string Address { get; set; }
-
-        [ExcelColumnName("办结时间")]
-        public DateTime ActualHandleTime { get; set; }
-
-        [ExcelColumnName("办结意见")]
-        public string ActualOpinion { get; set; }
+        [ExcelColumnName("乡镇")]
+        public string? Town { get; set; }
 
 
-        [ExcelColumnName("办结部门编号")]
-        public string ActualHandleOrgCode { get; set; }
+        [ExcelColumnName("事发地址")]
+        public string Street { get; set; }
 
 
-        [ExcelColumnName("办结部门")]
-        public string ActualHandleOrgName { get; set; }
+        [ExcelColumnName("来电人姓名")]
+        public string FromName { get; set; }
 
 
         [ExcelColumnName("联系电话")]
         [ExcelColumnName("联系电话")]
         public string Contact { get; set; }
         public string Contact { get; set; }
+        
+        [ExcelColumnName("重办次数")]
+        public int ReTransactNum { get; set; }
+        [ExcelColumnName("信件满意度")]
+        public string VisitResult { get; set; }
 
 
-        [ExcelColumnName("来电人身份")]
-        public EIdentityType IdentityType { get; set; }
+        [ExcelColumnName("受理内容")]
+        public string Content { get; set; }
 
 
-        [ExcelColumnName("工单状态")]
-        public EOrderStatus Status { get; set; }
+        [ExcelColumnName("承办意见")]
+        public string ActualOpinion { get; set; }
 
 
-        [ExcelColumnName("来源")]
-        public ESource Source { get; set; }
     }
     }
 }
 }

+ 15 - 0
src/Hotline/Orders/Order.cs

@@ -564,6 +564,21 @@ namespace Hotline.Orders
 
 
         #endregion
         #endregion
 
 
+        #region 二级部门
+
+        /// <summary>
+        /// 二级部门code
+        /// </summary>
+        [SugarColumn(IsNullable = true)]
+        public string? OrgLevelTwoCode { get; set; }
+        /// <summary>
+        /// 二级部门名称
+        /// </summary>
+        [SugarColumn(IsNullable = true)]
+        public string? OrgLevelTwoName { get; set; }
+
+        #endregion
+
         #region 受理人(开启流程的话务员)
         #region 受理人(开启流程的话务员)
 
 
         /// <summary>
         /// <summary>