|
|
@ -9,6 +9,7 @@ using System.Threading.Tasks; |
|
|
|
using Castle.Components.DictionaryAdapter; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using MyNamespace; |
|
|
|
using Volo.Abp; |
|
|
@ -43,8 +44,10 @@ public class AssembleIssueJobAppService |
|
|
|
private readonly IHttpClientFactory _httpClientFactory; |
|
|
|
private readonly ITransferLibRequestAppService _transferLibRequestAppService; |
|
|
|
private readonly IOptions<RestoOptions> _options; |
|
|
|
private readonly ILogger<AssembleIssueJobAppService> _logger; |
|
|
|
|
|
|
|
public AssembleIssueJobAppService( |
|
|
|
ILogger<AssembleIssueJobAppService> logger, |
|
|
|
IAssembleIssueJobRepository repository, IAssembleIssueJobManager assembleIssueJobManager, |
|
|
|
ILocationAppService locationAppService, |
|
|
|
IAssembleIssueNoteAppService assembleIssueNoteAppService, IExpectOutAppService expectOutAppService |
|
|
@ -59,6 +62,7 @@ public class AssembleIssueJobAppService |
|
|
|
_httpClientFactory = httpClientFactory; |
|
|
|
_options = options; |
|
|
|
_transferLibRequestAppService = transferLibRequestAppService; |
|
|
|
_logger = logger; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("get-by-number-2")] |
|
|
@ -296,24 +300,25 @@ public class AssembleIssueJobAppService |
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("sync-issue-job-stereo")] |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<AssembleIssueJobDTO> input, string pLoc) |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<AssembleIssueJobDTO> input, string pLoc,Guid uid) |
|
|
|
{ |
|
|
|
var ret = new ReusltObject(); |
|
|
|
ret.Code = "1"; |
|
|
|
ret.Code = 0; |
|
|
|
ret.Message = "操作成功"; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
try |
|
|
|
{ |
|
|
|
var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>(); |
|
|
|
var main = new IssueJobToRestoDTO(); |
|
|
|
main.OperatorName = CurrentUser.UserName; |
|
|
|
main.Uuid = uid; |
|
|
|
main.OperatorName = string.IsNullOrEmpty(CurrentUser.UserName)? "admin": CurrentUser.UserName; |
|
|
|
foreach (var job in input) |
|
|
|
{ |
|
|
|
foreach (var jobitem in job.Details) |
|
|
|
{ |
|
|
|
IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO |
|
|
|
{ |
|
|
|
Count = jobitem.HandledToQty, |
|
|
|
Count = jobitem.RecommendFromQty, |
|
|
|
ProductNo = jobitem.ItemCode, |
|
|
|
NeedSite = pLoc, |
|
|
|
WorkNo = job.Number, |
|
|
@ -333,6 +338,20 @@ public class AssembleIssueJobAppService |
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//var json = JsonSerializer.Serialize(main);
|
|
|
|
_options.Value.Address = "http://7e42682n64.goho.co:21171/"; //测试地址
|
|
|
|
_options.Value.Token = ""; //测试token
|
|
|
|
_options.Value.UserName = ""; //测试用户名
|
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
_options.Value.Path = "zozocnApi/custom/receiveProductionPlan"; //测试密码
|
|
|
|
|
|
|
|
_logger.LogInformation(System.Text.Json.JsonSerializer.Serialize(_options)); |
|
|
|
|
|
|
|
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|
|
|
_logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{System.Text.Json.JsonSerializer.Serialize(main)}"); |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_options.Value.Token)) |
|
|
|
{ |
|
|
|
var token = _options.Value.Token; |
|
|
@ -349,11 +368,13 @@ public class AssembleIssueJobAppService |
|
|
|
|
|
|
|
var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); |
|
|
|
ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); |
|
|
|
|
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{ret}"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new ReusltObject(); |
|
|
|
ret.Code = "2"; |
|
|
|
ret.Code = 1; |
|
|
|
ret.Message = ex.Message; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
} |
|
|
@ -368,7 +389,7 @@ public class AssembleIssueJobAppService |
|
|
|
var json = JsonSerializer.Serialize(input); |
|
|
|
#endif
|
|
|
|
var errors = new List<string>(); |
|
|
|
var ret = new ReusltObject { Code = "1", OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = "操作成功" }; |
|
|
|
var ret = new ReusltObject { Code = int.Parse(GaoTongResultStatus.Success), OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = "操作成功" }; |
|
|
|
try |
|
|
|
{ |
|
|
|
if (input.Jobs.Count > 0) |
|
|
@ -378,6 +399,12 @@ public class AssembleIssueJobAppService |
|
|
|
var query = _repository.WithDetails() |
|
|
|
.Where(p => numbers.Contains(p.Number)); |
|
|
|
var entities = query.ToList(); |
|
|
|
if (entities.Count == 0) |
|
|
|
{ |
|
|
|
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var dtos = ObjectMapper.Map<List<AssembleIssueJob>, List<AssembleIssueJobDTO>>(entities); |
|
|
|
if (input.Jobs.Count == entities.Count) |
|
|
|
{ |
|
|
@ -417,7 +444,7 @@ public class AssembleIssueJobAppService |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = "2", OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = ex.Message |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = ex.Message |
|
|
|
}; |
|
|
|
return ret; |
|
|
|
} |
|
|
@ -426,7 +453,7 @@ public class AssembleIssueJobAppService |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = "2", |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
@ -510,6 +537,8 @@ public class AssembleIssueJobAppService |
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckDimensionalStorehouseAsync(AssembleIssueJobEditInput input) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
@ -528,17 +557,19 @@ public class AssembleIssueJobAppService |
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckDimensionalStorehouseAsync(AssembleIssueJobDTO assembleIssueJobDto) |
|
|
|
{ |
|
|
|
|
|
|
|
var jobDetailInputdetail = assembleIssueJobDto.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
//TODO 立体库
|
|
|
|
var ret = await SyncIssueJobStereoAsync(new List<AssembleIssueJobDTO> { assembleIssueJobDto }, |
|
|
|
loctionDto.Code).ConfigureAwait(false); |
|
|
|
if (ret.Code != "1") |
|
|
|
loctionDto.Code,assembleIssueJobDto.Id).ConfigureAwait(false); |
|
|
|
if (ret.Code != 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); |
|
|
|
} |
|
|
|