|
@ -6,6 +6,7 @@ using System.Net.Http; |
|
|
using System.Net.NetworkInformation; |
|
|
using System.Net.NetworkInformation; |
|
|
using System.Security.Policy; |
|
|
using System.Security.Policy; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
|
|
|
using System.Text.Json; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Dy_Exchange.Enums; |
|
|
using Dy_Exchange.Enums; |
|
@ -13,6 +14,8 @@ using Dy_Exchange.Permissions; |
|
|
using Dy_Exchange.Z_Business.Dtos; |
|
|
using Dy_Exchange.Z_Business.Dtos; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
@ -33,6 +36,7 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
protected override string UpdatePolicyName { get; set; } = Dy_ExchangePermissions.DataExchangeInterfaceConfig.Update; |
|
|
protected override string UpdatePolicyName { get; set; } = Dy_ExchangePermissions.DataExchangeInterfaceConfig.Update; |
|
|
protected override string DeletePolicyName { get; set; } = Dy_ExchangePermissions.DataExchangeInterfaceConfig.Delete; |
|
|
protected override string DeletePolicyName { get; set; } = Dy_ExchangePermissions.DataExchangeInterfaceConfig.Delete; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string wmsCode = "WMS"; |
|
|
public string wmsCode = "WMS"; |
|
|
public string cmdStartPath = @"D:\Proc_DyNevWms\publish\start.cmd"; |
|
|
public string cmdStartPath = @"D:\Proc_DyNevWms\publish\start.cmd"; |
|
|
public string cmdClosePath1 = @"D:\Proc_DyNevWms\publish\stop.cmd"; |
|
|
public string cmdClosePath1 = @"D:\Proc_DyNevWms\publish\stop.cmd"; |
|
@ -40,10 +44,17 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
public string wmsUrl = "http://10.164.233.5:60085/swagger/AbpTenant/swagger.json"; |
|
|
public string wmsUrl = "http://10.164.233.5:60085/swagger/AbpTenant/swagger.json"; |
|
|
|
|
|
|
|
|
private readonly IDataExchangeInterfaceConfigRepository _repository; |
|
|
private readonly IDataExchangeInterfaceConfigRepository _repository; |
|
|
|
|
|
private readonly IOptions<DataExchangeInterfaceOptions> _options; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DataExchangeInterfaceConfigAppService(IDataExchangeInterfaceConfigRepository repository) : base(repository) |
|
|
public DataExchangeInterfaceConfigAppService(IDataExchangeInterfaceConfigRepository repository, IOptions<DataExchangeInterfaceOptions> options) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
|
|
|
|
_options = options; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost("CheckWmsStatusAsync")] |
|
|
[HttpPost("CheckWmsStatusAsync")] |
|
@ -55,6 +66,7 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
|
|
|
|
|
|
public static bool IsPortInUse(int port) |
|
|
public static bool IsPortInUse(int port) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
bool inUse = false; |
|
|
bool inUse = false; |
|
|
|
|
|
|
|
|
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); |
|
|
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); |
|
@ -117,7 +129,7 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
public async Task<bool> CloseWmsAsync() |
|
|
public async Task<bool> CloseWmsAsync() |
|
|
{ |
|
|
{ |
|
|
var list=await _repository.GetListAsync().ConfigureAwait(false); |
|
|
var list=await _repository.GetListAsync().ConfigureAwait(false); |
|
|
var removeWmsCodeList=list.Where(p => p.Code != wmsCode).ToList(); |
|
|
var removeWmsCodeList=list.Where(p => p.Code != _options.Value.WmsCode).ToList(); |
|
|
if (removeWmsCodeList.Any(p => p.Status == EnumStatus.Running||p.Active==true)) |
|
|
if (removeWmsCodeList.Any(p => p.Status == EnumStatus.Running||p.Active==true)) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException($"有未关闭的接口程序{removeWmsCodeList.First().Code}无法关闭WMS"); |
|
|
throw new UserFriendlyException($"有未关闭的接口程序{removeWmsCodeList.First().Code}无法关闭WMS"); |
|
@ -131,15 +143,15 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
throw new UserFriendlyException($"接口刚刚关闭,请5分钟后再关闭WMS。最后一次关闭时间相差{Math.Abs((int)difference.TotalMinutes)}分钟"); |
|
|
throw new UserFriendlyException($"接口刚刚关闭,请5分钟后再关闭WMS。最后一次关闭时间相差{Math.Abs((int)difference.TotalMinutes)}分钟"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var wmsConfig=await _repository.FindAsync(p => p.Code == wmsCode).ConfigureAwait(false); |
|
|
var wmsConfig=await _repository.FindAsync(p => p.Code == _options.Value.WmsCode).ConfigureAwait(false); |
|
|
if (wmsConfig == null) |
|
|
if (wmsConfig == null) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException("未找到WMS配置项目"); |
|
|
throw new UserFriendlyException("未找到WMS配置项目"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var stop1= ExecuteBatFile(cmdClosePath1); |
|
|
var stop1= ExecuteBatFile(_options.Value.CmdClosePath1); |
|
|
Thread.Sleep(2000); // 休眠2秒
|
|
|
Thread.Sleep(2000); // 休眠2秒
|
|
|
var stop2 = ExecuteBatFile(cmdClosePath2); |
|
|
var stop2 = ExecuteBatFile(_options.Value.CmdClosePath2); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -157,9 +169,9 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
[HttpPut("Base/Update")] |
|
|
[HttpPut("Base/Update")] |
|
|
public override async Task<DataExchangeInterfaceConfigDto> UpdateAsync(Guid id, CreateUpdateDataExchangeInterfaceConfigDto input) |
|
|
public override async Task<DataExchangeInterfaceConfigDto> UpdateAsync(Guid id, CreateUpdateDataExchangeInterfaceConfigDto input) |
|
|
{ |
|
|
{ |
|
|
if (input.Code != wmsCode&&input.Active==true) |
|
|
if (input.Code != _options.Value.WmsCode&&input.Active==true) |
|
|
{ |
|
|
{ |
|
|
bool isPageLoaded = await IsPageLoadedSuccessfullyAsync(wmsUrl).ConfigureAwait(false); |
|
|
bool isPageLoaded = await IsPageLoadedSuccessfullyAsync(_options.Value.WmsUrl).ConfigureAwait(false); |
|
|
if (!isPageLoaded) |
|
|
if (!isPageLoaded) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException("WMS未启动成功,请稍后再启动接口"); |
|
|
throw new UserFriendlyException("WMS未启动成功,请稍后再启动接口"); |
|
@ -167,12 +179,12 @@ public class DataExchangeInterfaceConfigAppService : ZbxBase<DataExchangeInterfa |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//开启wms
|
|
|
//开启wms
|
|
|
if (input.Code == wmsCode&&input.Active==true) |
|
|
if (input.Code == _options.Value.WmsCode&&input.Active==true) |
|
|
{ |
|
|
{ |
|
|
input.Status = EnumStatus.Running; |
|
|
input.Status = EnumStatus.Running; |
|
|
await StartWmsAsync().ConfigureAwait(false); |
|
|
await StartWmsAsync().ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
if(input.Code == wmsCode && input.Active == false) |
|
|
if(input.Code == _options.Value.WmsCode && input.Active == false) |
|
|
{ |
|
|
{ |
|
|
input.Status = EnumStatus.Closed; |
|
|
input.Status = EnumStatus.Closed; |
|
|
await CloseWmsAsync().ConfigureAwait(false); |
|
|
await CloseWmsAsync().ConfigureAwait(false); |
|
|