using Hotline.Orders; using Hotline.Settings; using Hotline.Settings.TimeLimitDomain; using Hotline.Settings.TimeLimitDomain.Repository; using Hotline.Share.Dtos.Settings; using Hotline.Share.Enums.FlowEngine; using Hotline.Share.Enums.Order; using Hotline.Share.Enums.Settings; using Hotline.Share.Tools; using Shouldly; using XF.Domain.Repository; namespace Hotline.Tests.Domain; public class ZiGongExpireTimeTest { private readonly ZiGongExpireTimeLimit _ziGongExpireTimeLimit; private readonly IRepository _orderRepository; private readonly ITimeLimitSettingAttributeRepository _timeLimitSettingAttributeRepository; private readonly ITimeLimitSettingInventoryRepository _timeLimitSettingInventoryRepository; public ZiGongExpireTimeTest(ZiGongExpireTimeLimit ziGongExpireTimeLimit, IRepository orderRepository, ITimeLimitSettingAttributeRepository timeLimitSettingAttributeRepository, ITimeLimitSettingInventoryRepository timeLimitSettingInventoryRepository) { _ziGongExpireTimeLimit = ziGongExpireTimeLimit; _orderRepository = orderRepository; _timeLimitSettingAttributeRepository = timeLimitSettingAttributeRepository; _timeLimitSettingInventoryRepository = timeLimitSettingInventoryRepository; } [Theory] [InlineData("企业咨询件单元测试", false, "Enterprise","10","互联网", "2024-09-04 14:00:00", "CenterToOrg", "2024-09-05 13:59:59")] [InlineData("企业建议件单元测试", false, "Enterprise","15","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 13:59:59")] [InlineData("企业求助件单元测试", false, "Enterprise","20","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 13:59:59")] [InlineData("企业表扬件单元测试", false, "Enterprise","25","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 13:59:59")] [InlineData("企业举报件单元测试", false, "Enterprise","30","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 13:59:59")] [InlineData("企业投诉件单元测试", false, "Enterprise","35","互联网", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-09 13:59:59")] [InlineData("四川省12345咨询件单测试",false, "Citizen", "10","四川省12345", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-06 13:59:59")] [InlineData("四川省12345建议件单测试",false, "Citizen", "15","四川省12345", "2024-09-05 14:00:00", "CenterToOrg", "2024-09-10 13:59:59")] [InlineData("中心到中心24小时", true, "Citizen", "10","四川省12345", "2024-09-12 14:00:00", "CenterToCenter", "2024-09-13 14:00:00")] public async Task CalcExpiredTime_Test(string title, bool is24, string identityType,string acceptTypeCode, string sourceChannel, string beginTxt, string flowTxt, string expected) { var beginTime = DateTime.Parse(beginTxt); Enum.TryParse(flowTxt, out EFlowDirection flow); var inDto = new OrderTimeClacInfo { IdentityType = identityType.ToEnum(), AcceptTypeCode = acceptTypeCode, SourceChannel = sourceChannel, FlowDirection = flow, Is24HoursComplete = is24 }; var time = await _ziGongExpireTimeLimit.CalcExpiredTime(beginTime,beginTime, flow, inDto); time.ShouldNotBeNull(); time.ExpiredTime.ShouldBe(DateTime.Parse(expected), $"{title} 期满时间错误 AcceptTypeCode:{acceptTypeCode}"); } [Theory] [InlineData("", "Is24HoursComplete", "true", false)] [InlineData("", "HotspotSpliceName", "疫情", false)] [InlineData("10", "IdentityType", "Enterprise", false)] [InlineData("15", "IdentityType", "Enterprise", false)] [InlineData("20", "IdentityType", "Enterprise", false)] public async Task InitTimeLimitData_Test(string busCode, string name, string value, bool isCommon) { return; var attributeEntity = new TimeLimitSettingAttribute { BusCode = busCode, Name = name, Value = value, IsCommon = isCommon }; var dataEntity = await _timeLimitSettingAttributeRepository.GetAsync(attributeEntity.BusCode, attributeEntity.Name, attributeEntity.Value); if (dataEntity is null) await _timeLimitSettingAttributeRepository.AddAsync(attributeEntity); } [Theory] [InlineData("", "Is24HoursComplete", "true", "Hour", 24, "24小时件")] [InlineData("", "HotspotSpliceName", "疫情", "WorkDay", 2, "疫情类2个工作日")] [InlineData("10", "IdentityType", "Enterprise", "WorkDay", 1, "企业 '咨询' 件1个工作日")] [InlineData("", "IdentityType", "Enterprise", "WorkDay", 2, "企业 '非咨询' 件2个工作日")] [InlineData("10", "SourceChannel", "四川省12345", "WorkDay", 1, "四川省12345 '咨询' 件1个工作日")] [InlineData("", "SourceChannel", "四川省12345", "WorkDay", 3, "四川省12345 '非咨询' 件3个工作日")] [InlineData("10", "SourceChannel", "省政民互动", "WorkDay", 1, "省政民互动 '咨询' 件1个工作日")] [InlineData("", "SourceChannel", "省政民互动", "WorkDay", 3, "省政民互动 '非咨询' 件3个工作日")] [InlineData("10", "SourceChannel", "国家政务平台", "WorkDay", 1, "国家政务平台 '咨询' 件1个工作日")] [InlineData("", "SourceChannel", "国家政务平台", "WorkDay", 3, "国家政务平台 '非咨询' 件3个工作日")] [InlineData("10", "SourceChannel", "天府通办", "WorkDay", 1, "天府通办 '咨询' 件1个工作日")] [InlineData("", "SourceChannel", "天府通办", "WorkDay", 3, "天府通办 '非咨询' 件3个工作日")] [InlineData("10", "SourceChannel", "中国政府网", "WorkDay", 1, "中国政府网 '咨询' 件1个工作日")] [InlineData("", "SourceChannel", "中国政府网", "WorkDay", 3, "中国政府网 '非咨询' 件3个工作日")] public async Task InitTimeLimitInventory_Test(string busCode, string name, string value, string timeType, int timeValue, string remark) { return; var attributeEntity = new TimeLimitSettingAttribute { BusCode = busCode, Name = name, Value = value, IsCommon = false }; var dataEntity = await _timeLimitSettingAttributeRepository.GetAsync(attributeEntity.BusCode, attributeEntity.Name, attributeEntity.Value); if (dataEntity is null) await _timeLimitSettingAttributeRepository.AddAsync(attributeEntity); var attribute = await _timeLimitSettingAttributeRepository.GetAsync(busCode, name, value); attribute.ShouldNotBeNull($"{name} 属性未初始化"); Enum.TryParse(timeType, out ETimeType eTimeType); var entity = new TimeLimitSettingInventory { Code = attribute.Code.ToString(), TimeType = eTimeType, TimeValue = timeValue, Percentage = 80, PercentageOne = 50 , Remark = remark}; var m = await _timeLimitSettingInventoryRepository.GetByCode(entity.Code); if (m is null) await _timeLimitSettingInventoryRepository.AddAsync(entity); } }