diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/BaseDatas/ItemContainerController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/BaseDatas/ItemContainerController.cs new file mode 100644 index 000000000..ac9c15b66 --- /dev/null +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/BaseDatas/ItemContainerController.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Win_in.Sfs.Basedata.Application.Contracts; + +namespace Win_in.Sfs.Wms.Pda.Controllers.BaseDatas; + +/// +/// +[ApiController] +[Route($"{PdaHostConst.ROOT_ROUTE}item-container")] +public class ItemContainerController : AbpController +{ + private readonly IItemContainerAppService _itemContainerAppService; + + public ItemContainerController(IItemContainerAppService itemContainerAppService) + { + _itemContainerAppService = itemContainerAppService; + } + + /// + /// 根据名称获取物品 + /// + /// + /// + [HttpGet("by-item")] + public virtual async Task GetListByItemNameAsync(string itemCode) + { + var dto = await _itemContainerAppService.GetByItemCodeAsync(itemCode).ConfigureAwait(false); + + return dto; + } +} diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/KittingIssueJobsController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/KittingIssueJobsController.cs new file mode 100644 index 000000000..85558bfe0 --- /dev/null +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/KittingIssueJobsController.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; +using Win_in.Sfs.Auth.Application.Contracts; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.Pda.Controllers.Jobs.IssueJobs; + +/// +/// +[ApiController] +[Route($"{PdaHostConst.ROOT_ROUTE}job/kitting-issue")] +public class KittingIssueJobsController : AbpController +{ + private readonly IKittingIssueJobAppService _kittingIssueJobAppService; + + private readonly IUserWorkGroupAppService _userWorkGroupAppService; + + public KittingIssueJobsController(IKittingIssueJobAppService kittingIssueJobAppService, IUserWorkGroupAppService userWorkGroupAppService) + { + _kittingIssueJobAppService = kittingIssueJobAppService; + _userWorkGroupAppService = userWorkGroupAppService; + } + + /// + /// 获取列表 + /// + /// + /// + /// + /// + [HttpPost("list")] + public virtual async Task> GetListAsync(int pageSize, int pageIndex, + bool isFinished) + { + var status = new List(); + if (isFinished) + { + status.Add((int)EnumJobStatus.Done); + } + else + { + status.Add((int)EnumJobStatus.Open); + status.Add((int)EnumJobStatus.Wait); + status.Add((int)EnumJobStatus.Doing); + status.Add((int)EnumJobStatus.Partial); + } + + var jsonStatus = JsonSerializer.Serialize(status); + + var request = new SfsJobRequestInputBase + { + MaxResultCount = pageSize, + SkipCount = (pageIndex - 1) * pageSize, + Sorting = $"{nameof(ContainerJobDTO.CreationTime)} ASC", + Condition = new Condition + { + Filters = new List { new(nameof(ContainerJobDTO.JobStatus), jsonStatus, "In") } + } + }; + + var list = await _kittingIssueJobAppService.GetPagedListByFilterAsync(request, true).ConfigureAwait(false); + + return list; + } + + /// + /// 承接任务 + /// + /// + /// + [HttpPost("take/{id}")] + public virtual async Task TakeAsync(Guid id) + { + await _kittingIssueJobAppService.AcceptAsync(id).ConfigureAwait(false); + } + + /// + /// 取消承接任务 + /// + /// + /// + [HttpPost("cancel-take/{id}")] + public virtual async Task CancelTakeAsync(Guid id) + { + await _kittingIssueJobAppService.CancelAcceptAsync(id).ConfigureAwait(false); + } + + /// + /// 执行任务明细 + /// + /// + [HttpPost("ExecuteDetail/{masterId}")] + public async Task ExecuteDetailAsync(Guid masterId, Guid detailId, KittingIssueJobDetailDTO issueJobDetailDto) + { + await _kittingIssueJobAppService.ExecuteDetailAsync(masterId,detailId,issueJobDetailDto).ConfigureAwait(false); + } + + /// + /// 获取任务数量 + /// + /// + [HttpGet("count")] + public virtual async Task> CountAsync() + { + var status = new List + { + (int)EnumJobStatus.Open, (int)EnumJobStatus.Doing, (int)EnumJobStatus.Partial, (int)EnumJobStatus.Wait + }; + var jsonStatus = JsonSerializer.Serialize(status); + + var request = new SfsJobRequestInputBase + { + Sorting = $"{nameof(InspectJobDTO.Priority)} ASC", + Condition = new Condition + { + Filters = new List + { + //new(nameof(InspectJobDTO.WorkGroupCode),jsonCodes,"In"), + new(nameof(InspectJobDTO.JobStatus), jsonStatus, "In") + } + } + }; + + var count = await _kittingIssueJobAppService.GetCountByFilterAsync(request).ConfigureAwait(false); + + return Ok(count); + } + + /// + /// 获取任务详情 + /// + /// + /// + [HttpGet("{id}")] + public virtual async Task> GetAsync(Guid id) + { + var result = await _kittingIssueJobAppService.GetAsync(id).ConfigureAwait(false); + return Ok(result); + } + + /// + /// 根据Job Number 获取盘点任务列表 + /// + /// + /// + [HttpGet("by-number/{jobNumber}")] + public virtual async Task> GetByNumberAsync(string jobNumber) + { + var jobDto = await _kittingIssueJobAppService.GetByNumberAsync(jobNumber).ConfigureAwait(false); + if (jobDto == null) + { + throw new UserFriendlyException($"未找到编号为 {jobNumber} 的任务"); + } + + var wlgCodes = await _userWorkGroupAppService.GetCodsOfCurrentUserAsync().ConfigureAwait(false); + if (!wlgCodes.Contains(jobDto.WorkGroupCode)) + { + return new NotFoundObjectResult($"任务属于工作组 {jobDto.WorkGroupCode}"); + } + + if (jobDto.JobStatus == EnumJobStatus.Doing && jobDto.AcceptUserId != CurrentUser.Id) + { + return new NotFoundObjectResult($"任务正在被 {jobDto.AcceptUserName} 处理"); + } + + return jobDto; + } +} diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/TransferLibJobController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/TransferLibJobController.cs similarity index 99% rename from be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/TransferLibJobController.cs rename to be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/TransferLibJobController.cs index c8084e7d7..5caf96652 100644 --- a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/TransferLibJobController.cs +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/TransferLibJobController.cs @@ -31,7 +31,7 @@ public class TransferLibJobController : AbpController } /// - /// 获取盘点任务详情 + /// /// /// /// diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/IssueRequest/KittingRequestController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/IssueRequest/KittingRequestController.cs new file mode 100644 index 000000000..c24e85e69 --- /dev/null +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/IssueRequest/KittingRequestController.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; +using Win_in.Sfs.Auth.Application.Contracts; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.Pda.Controllers.Stores; + +/// +/// Kitting叫料请求 +/// +[ApiController] +[Route($"{PdaHostConst.ROOT_ROUTE}store/kitting-request")] +public class KittingRequestController : AbpController +{ + private readonly IKittingIssueRequestAppService _kittingIssueRequestAppService; + + private readonly IUserWorkGroupAppService _userWorkGroupAppService; + + /// + /// + /// + public KittingRequestController(IKittingIssueRequestAppService kittingIssueRequestAppService, + IUserWorkGroupAppService userWorkGroupAppService) + { + _kittingIssueRequestAppService = kittingIssueRequestAppService; + _userWorkGroupAppService = userWorkGroupAppService; + } + + /// + /// Kitting叫料申请 + /// + /// + /// + [HttpPost("")] + public virtual async Task CreateAsync(KittingIssueRequestEditInput input) + { + await _kittingIssueRequestAppService.CreateAndHandleAsync(input).ConfigureAwait(false); + } + + /// + /// + /// + /// + /// + /// + [HttpPost("list")] + public virtual async Task> GetListAsync(int pageSize, int pageIndex, + bool isFinished) + { + var status = new List(); + if (isFinished) + { + status.Add((int)EnumRequestStatus.Completed); + } + else + { + status.Add((int)EnumRequestStatus.Partial); + status.Add((int)EnumRequestStatus.Handling); + status.Add((int)EnumRequestStatus.New); + } + + var jsonStatus = JsonSerializer.Serialize(status); + + var request = new SfsStoreRequestInputBase + { + MaxResultCount = pageSize, + SkipCount = (pageIndex - 1) * pageSize, + Sorting = $"{nameof(ContainerJobDTO.CreationTime)} ASC", + Condition = new Condition + { + Filters = new List { new(nameof(ContainerJobDTO.JobStatus), jsonStatus, "In") } + } + }; + + var list = await _kittingIssueRequestAppService.GetPagedListByFilterAsync(request, true).ConfigureAwait(false); + + return list; + } + + /// + /// + /// + [HttpPost("handle/{id}")] + public virtual async Task HandleAsync(Guid id) + { + await _kittingIssueRequestAppService.HandleAsync(id).ConfigureAwait(false); + } + + /// + /// 根据Job Number 获取盘点任务列表 + /// + /// + /// + [HttpGet("by-number/{requestNumber}")] + public virtual async Task> GetByNumberAsync(string requestNumber) + { + var jobDto = await _kittingIssueRequestAppService.GetByNumberAsync(requestNumber).ConfigureAwait(false); + if (jobDto == null) + { + throw new UserFriendlyException($"未找到编号为 {requestNumber} 的请求"); + } + + return jobDto; + } + + /// + /// 获取任务详情 + /// + /// + /// + [HttpGet("{id}")] + public virtual async Task> GetAsync(Guid id) + { + var result = await _kittingIssueRequestAppService.GetAsync(id).ConfigureAwait(false); + return Ok(result); + } +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemContainers/IItemContainerAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemContainers/IItemContainerAppService.cs index 783e1ab02..4acdf4457 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemContainers/IItemContainerAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemContainers/IItemContainerAppService.cs @@ -8,4 +8,5 @@ public interface IItemContainerAppService : ISfsBaseDataAppServiceBase> GetListByItemCodeAsync(string itemCode); Task UpsertAndItemBasicUomAsync(string itemCode,decimal stdPackQty); + Task GetByItemCodeAsync(string itemCode); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemContainers/ItemContainerAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemContainers/ItemContainerAppService.cs index 4c21b2851..0c77e19ed 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemContainers/ItemContainerAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemContainers/ItemContainerAppService.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp; using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; @@ -81,7 +82,6 @@ public class ItemContainerAppService return dtos; } - protected override async Task ValidateImportModelAsync(ItemContainerImportInput importInput, List validationRresult) { await base.CheckItemBasicPackUomAsync(importInput.ItemCode, importInput.BasicUom, validationRresult).ConfigureAwait(false); @@ -97,4 +97,11 @@ public class ItemContainerAppService await _repository.UpsertAsync(entity).ConfigureAwait(false); await ItemBasicAppService.UpsertStdPackQtyAsync(itemCode, stdPackQty).ConfigureAwait(false); } + + [HttpPut("get-by-item")] + public async Task GetByItemCodeAsync(string itemCode) + { + var entity = await _repository.FindAsync(p => p.ItemCode == itemCode).ConfigureAwait(false); + return ObjectMapper.Map(entity); + } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs index 1859b5324..ade4d7ddb 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs @@ -28,4 +28,13 @@ public sealed class CommonHelper return DateTime.Now; } } + + public static string CurTimeStr + { + get + { + return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + } + } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs index f0e17a5b7..e5361fa7d 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs @@ -45,4 +45,6 @@ public interface IExpectOutAppService EnumInventoryStatus enumInventoryStatus, string lot, decimal qty); + + Task RemoveByNumberAsync(string number); } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs index 252ff34cd..1f93d1907 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs @@ -64,15 +64,24 @@ public class ExpectOutAppService if (expectOut != null) { expectOut.Qty -= qty; + if (expectOut.Qty == 0) + { + await _repository.DeleteAsync(expectOut).ConfigureAwait(false); + } + else + { + await _repository.UpdateAsync(expectOut).ConfigureAwait(false); + } } + } - if (expectOut.Qty == 0) - { - await _repository.DeleteAsync(expectOut).ConfigureAwait(false); - } - else + [HttpPost("remove/job-number")] + public virtual async Task RemoveByNumberAsync(string number) + { + var expectOut = await _repository.GetListAsync(p => p.JobNumber == number).ConfigureAwait(false); + if (expectOut != null && expectOut.Any()) { - await _repository.UpdateAsync(expectOut).ConfigureAwait(false); + await _repository.DeleteManyAsync(expectOut).ConfigureAwait(false); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultDTO.cs new file mode 100644 index 000000000..dce8b9274 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultDTO.cs @@ -0,0 +1,34 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Application.Dtos; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 库存转移记录-实体DTO //??TransferLib实体 +/// +public class GaoTongResultDTO : EntityDto +{ + /// + /// + /// + [Display(Name = "")] + public string Code { get; set; } + + /// + /// + /// + [Display(Name = "")] + public string Message { get; set; } + + /// + /// + /// + [Display(Name = "")] + public string OperateTime { get; set; } +} +/* +{"code":"1","message":"接收成功", +"operateTime":"2020-01-0513:50:01"} + +*/ diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultStatus.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultStatus.cs new file mode 100644 index 000000000..306df7ca1 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/DTOs/GaoTongResultStatus.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +public sealed class GaoTongResultStatus +{ + /// + /// 成功 + /// + public const string Success = "1"; + + /// + /// 失败 + /// + public const string Failure = "-1"; +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/GaoTongPermissions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/GaoTongPermissions.cs new file mode 100644 index 000000000..e5fc16d51 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/GaoTongPermissions.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Authorization.Permissions; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +public static class GaoTongPermissions +{ +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/IGaoTongAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/IGaoTongAppService.cs new file mode 100644 index 000000000..b7daebf3c --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/IGaoTongAppService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 立库接口 +/// +public interface IGaoTongAppService : IApplicationService +{ + /// + /// 组盘信息反馈到东阳WMS(喷涂完工转储) + /// + /// 组盘接口输入参数 + /// 立库接口通用输出参数 + Task FeedbackZuPanAsync(ZuPanEditInput input); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/Inputs/ZuPanEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/Inputs/ZuPanEditInput.cs new file mode 100644 index 000000000..743546879 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/GaoTongs/Inputs/ZuPanEditInput.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Application.Dtos; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 新增和更新基础DTO //??TransferLib实体 +/// +public class ZuPanEditInput : EntityDto +{ + [Display(Name = "产品编号:映射ERP料号")] + public string ItemCode { get; set; } + + [Display(Name = "器具号")] + public string ContainerCode { get; set; } + + [Display(Name = "数量")] + public string Qty { get; set; } + + [Display(Name = "固定值,在立库中配置。用于多立库时区分哪个立库")] + public string ToLocationCode { get; set; } + + [Display(Name = "由1.2接口中获取富维东阳MES提供的来源位置")] + public string FromLocationCode { get; set; } + +} +/* +{ + "ItemCode": "ERPCODE0001", + "Qty": 122, + "ContainerCode": "C111123", + "ToLocationCode": "W1", + "FromLocationCode": "WIPT" +} +*/ diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/DTOs/KittingIssueJobDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/DTOs/KittingIssueJobDTO.cs index 17ed6fcb3..2141ce1d8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/DTOs/KittingIssueJobDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/DTOs/KittingIssueJobDTO.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAppService.cs new file mode 100644 index 000000000..f898c8741 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAppService.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Services; +using Volo.Abp.Users; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Basedata.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain.Shared; + +namespace Win_in.Sfs.Wms.Store.Application; + +/// +/// 立库接口 +/// +//[Authorize] +[AllowAnonymous] +[Route($"{StoreConsts.RootPath}gao-tong")] +public class GaoTongAppService : ApplicationService, IGaoTongAppService +{ + private readonly IBalanceAppService _balanceAppService; + private readonly ITransferNoteAppService _transferNoteAppService; + private readonly CurrentUser _currentUser; + private readonly IItemBasicAppService _itemBasicAppService; + private readonly ILocationAppService _locationAppService; + + public GaoTongAppService( + IBalanceAppService balanceAppService + , ITransferNoteAppService transferNoteAppService + , CurrentUser currentUser + , IItemBasicAppService itemBasicAppService + ,ILocationAppService locationAppService) + { + _balanceAppService = balanceAppService; + _transferNoteAppService = transferNoteAppService; + _currentUser = currentUser; + _itemBasicAppService = itemBasicAppService; + _locationAppService = locationAppService; + } + /// + /// 组盘信息反馈到东阳WMS + /// + /// + /// + [HttpPost("feedback-zu-pan")] + public async Task FeedbackZuPanAsync(ZuPanEditInput input) + { + GaoTongResultDTO ret = new GaoTongResultDTO(); + try + { + ItemBasicDTO itemBasicObj = await _itemBasicAppService.GetByCodeAsync(input.ItemCode).ConfigureAwait(false); + if (itemBasicObj == null) + { + throw new UserFriendlyException($"{input.ItemCode}在Item表不存在!"); + } + + TransferNoteEditInput transferNoteEditInput = new TransferNoteEditInput(); + transferNoteEditInput.TenantId = null; + transferNoteEditInput.Remark = String.Empty; + transferNoteEditInput.Worker = _currentUser.UserName; + transferNoteEditInput.ActiveDate = CommonHelper.CurTime; + transferNoteEditInput.Type = EnumTransSubType.Transfer_Coating.ToString(); //喷涂完工转储 + transferNoteEditInput.UseOnTheWayLocation = false; + //transferNoteEditInput.number + //transferNoteEditInput.CallServerName + //transferNoteEditInput.Confirmed = true; + //transferNoteEditInput.ConfirmTime = CommonHelper.CurTime; + if (transferNoteEditInput.Details == null) + { + transferNoteEditInput.Details = new List(); + } + TransferNoteDetailInput detailObj = new TransferNoteDetailInput(); + transferNoteEditInput.Details.Add(detailObj); + detailObj.Remark = ""; + detailObj.ItemCode = input.ItemCode; + detailObj.ItemName = itemBasicObj.Name; + detailObj.ItemDesc1 = itemBasicObj.Desc1; + detailObj.ItemDesc2 = itemBasicObj.Desc2; + detailObj.Uom = itemBasicObj.BasicUom; + detailObj.Qty = input.Qty.TryToDecimalZero(); + detailObj.StdPackQty = itemBasicObj.StdPackQty; + + #region 去箱、去批、去托 + detailObj.FromPackingCode = String.Empty; + detailObj.ToPackingCode = String.Empty; + detailObj.FromContainerCode = String.Empty; + detailObj.ToContainerCode = String.Empty; + detailObj.FromLot = String.Empty; + detailObj.ToLot = String.Empty; + #endregion + + detailObj.SupplierBatch = String.Empty; + detailObj.ArriveDate = CommonHelper.CurTime; + detailObj.ProduceDate = CommonHelper.CurTime; + detailObj.ExpireDate = DateTime.MaxValue; + var fromLocationObj = await _locationAppService.GetByCodeAsync(input.FromLocationCode).ConfigureAwait(false); + if (fromLocationObj == null) + { + throw new UserFriendlyException($"{input.FromLocationCode}在Location表不存在!"); + } + detailObj.FromLocationCode = input.FromLocationCode; + detailObj.FromLocationArea = fromLocationObj.AreaCode; + detailObj.FromLocationGroup = fromLocationObj.LocationGroupCode; + detailObj.FromLocationErpCode = fromLocationObj.ErpLocationCode; + detailObj.FromWarehouseCode = fromLocationObj.WarehouseCode; + var toLocationObj = await _locationAppService.GetByCodeAsync(input.ToLocationCode).ConfigureAwait(false); + if (toLocationObj == null) + { + throw new UserFriendlyException($"{input.ToLocationCode}在Location表不存在!"); + } + detailObj.ToLocationCode = input.ToLocationCode; + detailObj.ToLocationArea = toLocationObj.AreaCode; + detailObj.ToLocationGroup = toLocationObj.LocationGroupCode; + detailObj.ToLocationErpCode = toLocationObj.ErpLocationCode; + detailObj.ToWarehouseCode = toLocationObj.WarehouseCode; + detailObj.FromStatus = EnumInventoryStatus.OK; + detailObj.ToStatus = EnumInventoryStatus.OK; + detailObj.OnTheWayLocationCode = String.Empty; + detailObj.Reason = ""; + var temp = await _transferNoteAppService.CreateAsync(transferNoteEditInput).ConfigureAwait(false); + ret.Code = GaoTongResultStatus.Success; + ret.Message = "接收成功"; + ret.OperateTime = CommonHelper.CurTimeStr; + return ret; + } + catch (Exception ex) + { + ret.Code = GaoTongResultStatus.Failure; + ret.Message = "FeedbackZuPanAsync执行失败:" + ex.Message; + ret.OperateTime = CommonHelper.CurTimeStr; + return ret; + } + } +} + diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAutoMapperProfile.cs new file mode 100644 index 000000000..5de41e865 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/GaoTongs/GaoTongAutoMapperProfile.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AutoMapper; + +namespace Win_in.Sfs.Wms.Store.Application; + +public partial class StoreApplicationAutoMapperProfile : Profile +{ + private void GaoTongAutoMapperProfile() + { + } +} + diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs index 848f90ada..3a40b641d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs @@ -209,7 +209,9 @@ public class KittingIssueJobAppService if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) { input.JobStatus = EnumJobStatus.Wait; - + } + else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) + { jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; @@ -278,6 +280,8 @@ public class KittingIssueJobAppService kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, kittingIssueJobDetailDto.HandledToQty).ConfigureAwait(false); + await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); + await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber) .ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs index 2e3025d3c..29ab23d85 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs @@ -137,5 +137,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile ChassisOperationSequenceAutoMapperProfile(); KittingPackagingNoteAutoMapperProfile(); + //高通WMS-立库接口 + GaoTongAutoMapperProfile(); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs index b22c253d6..09a3b16e9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs @@ -32,5 +32,18 @@ public enum EnumExchangeDataType //回收料调整 Item_Transform = 28, //半成品上架 - SemiPutaway = 29 + SemiPutaway = 29, + /// + /// 注塑发料 + /// + InjectionIssue=30, + /// + /// 涂装发料 + /// + CoatingIssue=31, + /// + /// 装配发料 + /// + AssembleIssue=32, + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/AssembleIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/AssembleIssueNoteEventHandler.cs new file mode 100644 index 000000000..bfcaccd94 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/AssembleIssueNoteEventHandler.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Notes.IssueNotes; + +namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; + +/// +/// 装配发料记录传给TYRP(线边仓领料单) +/// +public class AssembleIssueNoteEventHandler + : StoreDataExchangeEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.AssembleIssue; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddExchangeDataAsync(entity).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddExchangeDataAsync(entities).ConfigureAwait(false); + } + + protected override async Task AddExchangeDataAsync(List entities) + { + var dtos = ObjectMapper.Map, List>(entities); + foreach (var detail in dtos.SelectMany(dto => dto.Details)) + { + if (string.IsNullOrEmpty(detail.HandledFromLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledFromLocationErpCode = location.ErpLocationCode; + detail.HandledFromLocationGroup = location.LocationGroupCode; + detail.HandledFromLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledFromWarehouseCode)) + { + detail.HandledFromWarehouseCode = location.WarehouseCode; + } + } + } + + if (string.IsNullOrEmpty(detail.HandledToLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledToLocationErpCode = location.ErpLocationCode; + detail.HandledToLocationGroup = location.LocationGroupCode; + detail.HandledToLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledToWarehouseCode)) + { + detail.HandledToWarehouseCode = location.WarehouseCode; + } + } + } + + } + + var toErpDto = new List(); + foreach (var item in dtos) + { + if (item.Details != null && item.Details.Count != 0) + { + toErpDto.Add(item); + } + } + + //2023-12-6要求同储位不传入接口 按历史规则 + var result = new List(); + foreach (var assembleIssueNoteDto in toErpDto) + { + assembleIssueNoteDto.Details.RemoveAll(p => p.HandledFromLocationErpCode == p.HandledToLocationErpCode); + if (assembleIssueNoteDto.Details.Count > 0) + { + result.Add(assembleIssueNoteDto); + } + } + + if (result.Count > 0) + { + var exchangeDataerp = + await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, result) + .ConfigureAwait(false); + await AddManyAsync(exchangeDataerp).ConfigureAwait(false); + } + } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs new file mode 100644 index 000000000..523e5973f --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Notes.IssueNotes; + +namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; + +/// +/// 涂装发料记录传给TYRP(线边仓领料单) +/// +public class CoatingIssueNoteEventHandler + : StoreDataExchangeEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.CoatingIssue; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddExchangeDataAsync(entity).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddExchangeDataAsync(entities).ConfigureAwait(false); + } + + protected override async Task AddExchangeDataAsync(List entities) + { + var dtos = ObjectMapper.Map, List>(entities); + foreach (var detail in dtos.SelectMany(dto => dto.Details)) + { + if (string.IsNullOrEmpty(detail.HandledFromLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledFromLocationErpCode = location.ErpLocationCode; + detail.HandledFromLocationGroup = location.LocationGroupCode; + detail.HandledFromLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledFromWarehouseCode)) + { + detail.HandledFromWarehouseCode = location.WarehouseCode; + } + } + } + + if (string.IsNullOrEmpty(detail.HandledToLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledToLocationErpCode = location.ErpLocationCode; + detail.HandledToLocationGroup = location.LocationGroupCode; + detail.HandledToLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledToWarehouseCode)) + { + detail.HandledToWarehouseCode = location.WarehouseCode; + } + } + } + + } + + var toErpDto = new List(); + foreach (var item in dtos) + { + if (item.Details != null && item.Details.Count != 0) + { + toErpDto.Add(item); + } + } + + //2023-12-6要求同储位不传入接口 按历史规则 + var result = new List(); + foreach (var coatingIssueNoteDto in toErpDto) + { + coatingIssueNoteDto.Details.RemoveAll(p => p.HandledFromLocationErpCode == p.HandledToLocationErpCode); + if (coatingIssueNoteDto.Details.Count > 0) + { + result.Add(coatingIssueNoteDto); + } + } + + if (result.Count > 0) + { + var exchangeDataerp = + await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, result) + .ConfigureAwait(false); + await AddManyAsync(exchangeDataerp).ConfigureAwait(false); + } + } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs new file mode 100644 index 000000000..10600d8ce --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; + +/// +/// 注塑发料记录传给TYRP(线边仓领料单) +/// +public class InjectionIssueNoteEventHandler + : StoreDataExchangeEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.InjectionIssue; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddExchangeDataAsync(entity).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddExchangeDataAsync(entities).ConfigureAwait(false); + } + + protected override async Task AddExchangeDataAsync(List entities) + { + var dtos = ObjectMapper.Map, List>(entities); + foreach (var detail in dtos.SelectMany(dto => dto.Details)) + { + if(string.IsNullOrEmpty(detail.HandledFromLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledFromLocationErpCode = location.ErpLocationCode; + detail.HandledFromLocationGroup = location.LocationGroupCode; + detail.HandledFromLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledFromWarehouseCode)) + { + detail.HandledFromWarehouseCode = location.WarehouseCode; + } + } + } + + if(string.IsNullOrEmpty(detail.HandledToLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledToLocationErpCode = location.ErpLocationCode; + detail.HandledToLocationGroup = location.LocationGroupCode; + detail.HandledToLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledToWarehouseCode)) + { + detail.HandledToWarehouseCode = location.WarehouseCode; + } + } + } + + } + + var toErpDto = new List(); + foreach (var item in dtos) + { + if (item.Details != null && item.Details.Count != 0) + { + toErpDto.Add(item); + } + } + + //2023-12-6要求同储位不传入接口 按历史规则 + var result = new List(); + foreach (var injectionIssueNoteDto in toErpDto) + { + injectionIssueNoteDto.Details.RemoveAll(p => p.HandledFromLocationErpCode == p.HandledToLocationErpCode); + if (injectionIssueNoteDto.Details.Count > 0) + { + result.Add(injectionIssueNoteDto); + } + } + + if (result.Count > 0) + { + var exchangeDataerp = + await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, result) + .ConfigureAwait(false); + await AddManyAsync(exchangeDataerp).ConfigureAwait(false); + } + } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs index abd58f12a..7adb5dde4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs @@ -32,10 +32,9 @@ namespace Win_in.Sfs.Wms.Store.Event.DataExchanges await AddExchangeDataAsync(entity).ConfigureAwait(false); } - protected override async Task AddExchangeDataAsync(List entities) { - var dtos = ObjectMapper.Map, List>(entities); + var dtos = ObjectMapper.Map, List>(entities); var exchangeData = await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, EnumExchangeDataType.Transfer, dtos).ConfigureAwait(false); await AddManyAsync(exchangeData).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs index d4c7751e4..878b02ee0 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; using System.Threading.Tasks; -using AutoMapper.Internal; using Castle.Components.DictionaryAdapter; using Volo.Abp; using Volo.Abp.EventBus; @@ -36,7 +35,7 @@ public class KittingIssueRequestEventHandler ILocationAppService locationAppService, IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService //, IKittingIssueRequestManager kittingIssueRequestManager - ) + ) { _kittingIssueJobAppService = kittingIssueJobAppService; _productionLineAppService = productionLineAppService; @@ -223,11 +222,11 @@ public class KittingIssueRequestEventHandler detail.PositionCode = kittingIssueRequestDetail.PositionCode; detail.RecommendType = kittingIssueRequestDetail.RecommendType; detail.Uom = balance.Uom; - detail.ItemCode= balance.ItemCode; - detail.ItemDesc2= balance.ItemDesc2; - detail.ItemDesc1= balance.ItemDesc1; - detail.ItemName= balance.ItemName; - detail.ProdLine= kittingIssueRequestDetail.ProdLine; + detail.ItemCode = balance.ItemCode; + detail.ItemDesc2 = balance.ItemDesc2; + detail.ItemDesc1 = balance.ItemDesc1; + detail.ItemName = balance.ItemName; + detail.ProdLine = kittingIssueRequestDetail.ProdLine; detail.RequestQty = balance.Qty; detail.StdPackQty = kittingIssueRequestDetail.StdPackQty; detail.Status = balance.Status; @@ -247,8 +246,8 @@ public class KittingIssueRequestEventHandler detail.RecommendFromProduceDate = balance.ProduceDate; detail.RecommendFromArriveDate = balance.ArriveDate; detail.RecommendFromQty = balance.Qty; - detail.RecommendFromContainerCode= balance.ContainerCode; - detail.RecommendFromPackingCode= balance.PackingCode; + detail.RecommendFromContainerCode = balance.ContainerCode; + detail.RecommendFromPackingCode = balance.PackingCode; detail.RecommendToPackingCode = balance.PackingCode; detail.RecommendToContainerCode = balance.ContainerCode; @@ -283,7 +282,7 @@ public class KittingIssueRequestEventHandler detail.TransferLibFromProduceDate = balance.ProduceDate; detail.TransferLibFromArriveDate = balance.ArriveDate; detail.TransferLibFromQty = balance.Qty; - detail.TransferLibFromContainerCode= balance.ContainerCode; + detail.TransferLibFromContainerCode = balance.ContainerCode; detail.TransferLibFromPackingCode = balance.PackingCode; detail.TransferLibToPackingCode = balance.PackingCode; @@ -294,7 +293,7 @@ public class KittingIssueRequestEventHandler detail.TransferLibToLot = balance.Lot; detail.TransferLibToProduceDate = balance.ProduceDate; detail.TransferLibToArriveDate = balance.ArriveDate; - detail.TransferLibToQty = balance.Qty; + detail.TransferLibToQty = balance.Qty; detail.TransferLibToPackingCode = balance.PackingCode; detail.TransferLibFromLocationArea = balance.LocationArea; @@ -334,7 +333,7 @@ public class KittingIssueRequestEventHandler List useBalanceList) { var inputJobs = new List(); - + //已用的库存的集合 useBalanceList = useBalanceList; @@ -343,7 +342,7 @@ public class KittingIssueRequestEventHandler //当前零件的集合 var inputDetails = kittingIssueRequestDetailList; //获取请求下 这个零件和这个库位一个需要多少箱 - var sumBoxQty = inputDetails.Sum(p => p.BoxQty-p.IssuedQty); + var sumBoxQty = inputDetails.Sum(p => p.BoxQty - p.IssuedQty); //获取生产线 var productionLineDto = await _productionLineAppService .GetByLocationCodeAsync(inputDetails.First().ToLocationCode).ConfigureAwait(false); @@ -521,33 +520,32 @@ public class KittingIssueRequestEventHandler { var usableLocationCode = JsonSerializer.Deserialize>(productionLineItemDto.RawLocationCodeListJson); - if (!usableLocationCode.Any()) - { - break; - } - - //获取可用库存 - var input = new RecommendBalanceRequestInput - { - ItemCode = kittingIssueRequestDetail.ItemCode, - Qty = decimal.MaxValue, - Statuses = new EditableList { EnumInventoryStatus.OK }, - Locations = - JsonSerializer.Deserialize>(productionLineItemDto.RawLocationCodeListJson), - IsPackingCode = true - }; - var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); - - //因为是按箱叫料 先把值赋值给箱数量上 - kittingIssueRequestDetail.BoxQty = kittingIssueRequestDetail.Qty; - - if (usableList.Any()) + if (usableLocationCode.Any()) { - //因为是原料所以按箱叫料 - kittingIssueJobEditInputs.AddRange( - await CreateKittingIssueJobWithBoxQtyTypeAsync(kittingIssueRequest, - new EditableList { kittingIssueRequestDetail }, usableList, - useBalanceList).ConfigureAwait(false)); + //获取可用库存 + var input = new RecommendBalanceRequestInput + { + ItemCode = kittingIssueRequestDetail.ItemCode, + Qty = decimal.MaxValue, + Statuses = new EditableList { EnumInventoryStatus.OK }, + Locations = + JsonSerializer.Deserialize>(productionLineItemDto.RawLocationCodeListJson), + IsPackingCode = true + }; + var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); + + //因为是按箱叫料 先把值赋值给箱数量上 + kittingIssueRequestDetail.BoxQty = kittingIssueRequestDetail.Qty; + + if (usableList.Any()) + { + //因为是原料所以按箱叫料 + kittingIssueJobEditInputs.AddRange( + await CreateKittingIssueJobWithBoxQtyTypeAsync(kittingIssueRequest, + new EditableList { kittingIssueRequestDetail }, + usableList, + useBalanceList).ConfigureAwait(false)); + } } } @@ -556,56 +554,57 @@ public class KittingIssueRequestEventHandler { var usableLocationCode = JsonSerializer.Deserialize>(productionLineItemDto.ProductLocationCodeListJson); - if (!usableLocationCode.Any()) - { - break; - } - - //获取可用库存 - var input = new RecommendBalanceRequestInput - { - ItemCode = groupbyItemCodeAndProdLine.Key.ItemCode, - Qty = kittingIssueRequestDetail.Qty, - Statuses = new EditableList { EnumInventoryStatus.OK }, - Locations = - JsonSerializer.Deserialize>(productionLineItemDto.ProductLocationCodeListJson), - IsPackingCode = false - }; - var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); - var temp = usableList.ToList(); - - foreach (var balanceDto in usableList) //计算已经用过的库存 + if (usableLocationCode.Any()) { - var useBalanceDto = useBalanceList.Where(p => - p.ItemCode == balanceDto.ItemCode && p.LocationCode == balanceDto.LocationCode && - p.Lot == balanceDto.Lot && p.Status == balanceDto.Status && - p.PackingCode == balanceDto.PackingCode); - if (useBalanceDto.Any()) //如果不为NULL,就是用过了的库存 需要减去使用量 + //获取可用库存 + var input = new RecommendBalanceRequestInput { - balanceDto.Qty -= useBalanceDto.Sum(p => p.Qty); - if (balanceDto.Qty <= 0) + ItemCode = groupbyItemCodeAndProdLine.Key.ItemCode, + Qty = kittingIssueRequestDetail.Qty, + Statuses = new EditableList { EnumInventoryStatus.OK }, + Locations = + JsonSerializer.Deserialize>(productionLineItemDto + .ProductLocationCodeListJson), + IsPackingCode = false + }; + var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); + var temp = usableList.ToList(); + + foreach (var balanceDto in usableList) //计算已经用过的库存 + { + var useBalanceDto = useBalanceList.Where(p => + p.ItemCode == balanceDto.ItemCode && p.LocationCode == balanceDto.LocationCode && + p.Lot == balanceDto.Lot && p.Status == balanceDto.Status && + p.PackingCode == balanceDto.PackingCode); + if (useBalanceDto.Any()) //如果不为NULL,就是用过了的库存 需要减去使用量 { - temp.Remove(balanceDto); + balanceDto.Qty -= useBalanceDto.Sum(p => p.Qty); + if (balanceDto.Qty <= 0) + { + temp.Remove(balanceDto); + } } } - } - usableList = temp; + usableList = temp; - kittingIssueJobEditInputs.AddRange( - await CreateKittingIssueJobWithQtyTypeAsync(kittingIssueRequest, - new List { kittingIssueRequestDetail }, temp, - useBalanceList).ConfigureAwait(false)); + kittingIssueJobEditInputs.AddRange( + await CreateKittingIssueJobWithQtyTypeAsync(kittingIssueRequest, + new List { kittingIssueRequestDetail }, temp, + useBalanceList).ConfigureAwait(false)); + } } } } - if (kittingIssueJobEditInputs.Count > 0)//有库存 可以创建任务 + if (kittingIssueJobEditInputs.Count > 0) //有库存 可以创建任务 { //新增任务 - var addKittingIssueJobDtos= await _kittingIssueJobAppService.CreateManyAsync(kittingIssueJobEditInputs).ConfigureAwait(false); + var addKittingIssueJobDtos = await _kittingIssueJobAppService.CreateManyAsync(kittingIssueJobEditInputs) + .ConfigureAwait(false); - await UpdateKittingIssueRequestDetailQtyAsync(kittingIssueRequest, addKittingIssueJobDtos).ConfigureAwait(false); + await UpdateKittingIssueRequestDetailQtyAsync(kittingIssueRequest, addKittingIssueJobDtos) + .ConfigureAwait(false); return addKittingIssueJobDtos; } @@ -614,15 +613,17 @@ public class KittingIssueRequestEventHandler } /// - /// 修改请求的 已发 已收数量 + /// 修改请求的 已发 已收数量 /// /// /// /// - private async Task UpdateKittingIssueRequestDetailQtyAsync(KittingIssueRequest kittingIssueRequest, List addKittingIssueJobDtos) + private async Task UpdateKittingIssueRequestDetailQtyAsync(KittingIssueRequest kittingIssueRequest, + List addKittingIssueJobDtos) { //原有任务 - var existKittingIssueJobDtos = await _kittingIssueJobAppService.GetByRequestNumberAsync(kittingIssueRequest.Number) + var existKittingIssueJobDtos = await _kittingIssueJobAppService + .GetByRequestNumberAsync(kittingIssueRequest.Number) .ConfigureAwait(false); //新增的任务和已有的任务总和