tangjiang 4 ay önce
ebeveyn
işleme
fa0b50608b

+ 42 - 1
src/Hotline.Api/Controllers/JudicialManagementOrdersController.cs

@@ -1,4 +1,5 @@
-using Hotline.Api.Filter;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using Hotline.Api.Filter;
 using Hotline.Application.JudicialManagement;
 using Hotline.Caching.Interfaces;
 using Hotline.File;
@@ -189,6 +190,46 @@ namespace Hotline.Api.Controllers
             await _judicialManagementOrdersRepository.UpdateAsync(order, HttpContext.RequestAborted);
         }
 
+        /// <summary>
+        /// 关联执法部门
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPut]
+        [LogFilter("关联执法部门")]
+        public async Task AssociatedLawEnforcementAgencies([FromBody] AssociatedLawEnforcementAgenciesDto dto)
+        {
+            if (dto.LawEnforcementAgencies == null || dto.LawEnforcementAgencies.Count == 0)
+                throw UserFriendlyException.SameMessage("请选择执法部门");
+
+            var order = await _judicialManagementOrdersRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+            if (order == null)
+                throw UserFriendlyException.SameMessage("工单查询失败");
+            //处理执法部门
+            if (dto.LawEnforcementAgencies != null && dto.LawEnforcementAgencies.Any())
+            {
+                List<LawEnforcementAgencies> lawEnforcementAgencies = new();
+                foreach (var item in dto.LawEnforcementAgencies)
+                {
+                    lawEnforcementAgencies.Add(new LawEnforcementAgencies
+                    {
+                        OrderId = order.Id,
+                        OrderNo = order.No,
+                        OrderSoure = EOrderSoure.Enforcement,
+                        OrgCode = item.Value,
+                        OrgName = item.Key
+                    });
+                }
+                if (lawEnforcementAgencies != null && lawEnforcementAgencies.Any())
+                {
+                    await _lawEnforcementAgenciesRepository.AddRangeAsync(lawEnforcementAgencies, HttpContext.RequestAborted);
+                    order.LawEnforcementAgencies = dto.LawEnforcementAgencies;
+                    await _judicialManagementOrdersRepository.UpdateAsync(order, HttpContext.RequestAborted);
+                }
+            }
+
+        }
+
         /// <summary>
         /// 查询工单详情
         /// </summary>

+ 7 - 6
src/Hotline.Application/JudicialManagement/EnforcementApplication.cs

@@ -16,9 +16,9 @@ namespace Hotline.Application.JudicialManagement
     public class EnforcementApplication : IEnforcementApplication, IScopeDependency
     {
         private readonly IRepository<JudicialManagementOrders> _judicialManagementOrdersRepository;
-        private readonly IRepository<EnforcementOrdersHandler> _enforcementOrdersHandlerRepository;
         private readonly IMapper _mapper;
         private readonly ISessionContext _sessionContext;
+        private readonly IRepository<LawEnforcementAgencies> _lawEnforcementAgenciesRepository;
 
         /// <summary>
         /// 
@@ -27,16 +27,17 @@ namespace Hotline.Application.JudicialManagement
         /// <param name="enforcementOrdersHandlerRepository"></param>
         /// <param name="mapper"></param>
         /// <param name="sessionContext"></param>
+        /// <param name="lawEnforcementAgenciesRepository"></param>
         public EnforcementApplication(
            IRepository<JudicialManagementOrders> judicialManagementOrdersRepository,
-           IRepository<EnforcementOrdersHandler> enforcementOrdersHandlerRepository,
            IMapper mapper,
-           ISessionContext sessionContext)
+           ISessionContext sessionContext,
+           IRepository<LawEnforcementAgencies> lawEnforcementAgenciesRepository)
         {
             _judicialManagementOrdersRepository = judicialManagementOrdersRepository;
-            _enforcementOrdersHandlerRepository = enforcementOrdersHandlerRepository;
             _mapper = mapper;
             _sessionContext = sessionContext;
+            _lawEnforcementAgenciesRepository = lawEnforcementAgenciesRepository;
         }
 
         /// <summary>
@@ -139,7 +140,7 @@ namespace Hotline.Application.JudicialManagement
         /// <returns></returns>
         public ISugarQueryable<EmDepartmentalProcessingStatisticsDto> GetDepartmentalProcessingStatisticsAsync(DateTime StartTime, DateTime EndTime)
         {
-            return _enforcementOrdersHandlerRepository.Queryable()
+            return _lawEnforcementAgenciesRepository.Queryable()
                    .LeftJoin<JudicialManagementOrders>((h, o) => h.OrderId == o.Id)
                    .Where((h, o) => o.CreationTime >= StartTime && o.CreationTime <= EndTime && o.IsItCounted == true)
                     .GroupBy((h, o) => new
@@ -166,7 +167,7 @@ namespace Hotline.Application.JudicialManagement
         /// <returns></returns>
         public ISugarQueryable<EnforcementOrderListDto> GetDepartmentalProcessingStatisticsOrderListAsync(QueryDepartmentalProcessingStatisticsDto dto)
         {
-            return _enforcementOrdersHandlerRepository.Queryable()
+            return _lawEnforcementAgenciesRepository.Queryable()
                  .LeftJoin<JudicialManagementOrders>((x, o) => x.OrderId == o.Id)
                  .Where((x, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null && o.IsItCounted == true)
                  .WhereIF(!string.IsNullOrEmpty(dto.OrgCode) && dto.OrgCode == "001", (x, o) => x.OrgCode == dto.OrgCode)

+ 13 - 1
src/Hotline.Share/Dtos/JudicialManagement/EnforcementOrderListDto.cs

@@ -93,7 +93,7 @@ namespace Hotline.Share.Dtos.JudicialManagement
         /// 是否行政执法类
         /// </summary>
         public bool? IsEnforcementOrder { get; set; }
-        public string? IsEnforcementOrderText  => CalcRate(IsEnforcementOrder);
+        public string? IsEnforcementOrderText => CalcRate(IsEnforcementOrder);
 
         /// <summary>
         /// 是否推诿
@@ -164,6 +164,7 @@ namespace Hotline.Share.Dtos.JudicialManagement
         public List<Kv> LawEnforcementAgencies { get; set; }
         public string LawEnforcementAgenciesText => GetLawEnforcementAgenciesText();
 
+        public bool IsAddLawEnforcementAgencies => IsAddLawEnforcementAgenciesTe();
         public string GetText()
         {
             string strOrgName = "";
@@ -194,6 +195,17 @@ namespace Hotline.Share.Dtos.JudicialManagement
             return strOrgName;
         }
 
+        /// <summary>
+        /// 如果执法部门为空,那么可以关联,如果执法部门不为空,则可以关联
+        /// </summary>
+        /// <returns></returns>
+        public bool IsAddLawEnforcementAgenciesTe()
+        {
+            if (LawEnforcementAgencies != null && LawEnforcementAgencies.Count > 0)
+                return false;
+            return true;
+        }
+
         /// <summary>
         /// 转换是否文本
         /// </summary>

+ 10 - 0
src/Hotline.Share/Dtos/JudicialManagement/JudicialManagementAddOrderDto.cs

@@ -252,4 +252,14 @@ namespace Hotline.Share.Dtos.JudicialManagement
             return $"{Province}{City}{County}{Town}";
         }
     }
+
+    public class AssociatedLawEnforcementAgenciesDto
+    {
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 执法部门
+        /// </summary>
+        public List<Kv> LawEnforcementAgencies { get; set; }
+    }
 }