Administrator
3 years ago
9 changed files with 804 additions and 215 deletions
@ -0,0 +1,391 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Caching.Distributed; |
||||
|
using AutoMapper; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Caching; |
||||
|
|
||||
|
using Volo.Abp.ObjectMapping; |
||||
|
using Win.Sfs.SettleAccount.ExcelImporter; |
||||
|
using Win.Sfs.Shared.CacheBase; |
||||
|
using Win.Utils; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Win.Sfs.BaseData.ImportExcelCommon; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using EFCore.BulkExtensions; |
||||
|
using System.IO; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Win.Sfs.SettleAccount.Entities.SettleAccountVersion; |
||||
|
using Win.Sfs.SettleAccount.FISes; |
||||
|
using Win.Sfs.Shared.Enums.SettleAccount; |
||||
|
using Win.Sfs.Shared.Filter; |
||||
|
using Shouldly; |
||||
|
using Magicodes.ExporterAndImporter.Csv; |
||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
using Magicodes.ExporterAndImporter.Excel; |
||||
|
using System.Data.Common; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Volo.Abp; |
||||
|
using Win.Abp.Snowflakes; |
||||
|
using Win.Sfs.SettleAccount.CommonManagers; |
||||
|
using Win.Sfs.SettleAccount.ExportReports; |
||||
|
using Win.Sfs.SettleAccount.Constant; |
||||
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
||||
|
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
||||
|
using Magicodes.ExporterAndImporter.Core.Models; |
||||
|
|
||||
|
using TaskJob.Services; |
||||
|
using TaskJob.EventArgs; |
||||
|
using Win.Sfs.SettleAccount.Entities.WMS; |
||||
|
using Win.Sfs.SettleAccount.Entities.Wms; |
||||
|
using Win.Sfs.SettleAccount.Repository; |
||||
|
using WY.NewJit.Extends.PaiGe.WMS; |
||||
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.WMS |
||||
|
{ |
||||
|
|
||||
|
[Route("api/settleaccount/wmskanbanoutputextend")] |
||||
|
[AllowAnonymous] |
||||
|
//[Authorize(SettleAccountPermissions.WMSJIT.Default)]
|
||||
|
public class WMSKanbanExtendAppService : SettleAccountApplicationBase<WmsWithOutKanbanOutPutDetial> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 大众看板-出库
|
||||
|
/// </summary>
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//private readonly ISettleAccountBranchEfCoreRepository<WmsKanbanOutPutDetial, Guid> _wmsRepository;
|
||||
|
//private readonly ISettleAccountBranchEfCoreRepository<WmsKanbanOutPut, Guid> _wmsVersionRepository;
|
||||
|
|
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsWithOutKanbanOutPutDetial, Guid> _wmsRepository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsWithOutKanbanOutPut, Guid> _wmsVersionRepository; |
||||
|
|
||||
|
private readonly KanbanUnSettledDapperRepository _dapper; |
||||
|
private readonly WMSEfCoreRepository<WmsKanbanOutPutDetial> _wmsefRespository; |
||||
|
|
||||
|
private readonly WMSEfCoreRepository<TB_BILL> _wmstbRespository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job; |
||||
|
private readonly IExcelImportAppService _excelImportService; |
||||
|
|
||||
|
|
||||
|
private readonly TaskJobService _service; |
||||
|
private readonly WmsDapperRepository _wmsDapper; |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="wmsRepository"></param>
|
||||
|
/// <param name="job"></param>
|
||||
|
/// <param name="wmsVersionRepository"></param>
|
||||
|
/// <param name="wmsefRespository"></param>
|
||||
|
/// <param name="wmstbRespository"></param>
|
||||
|
public WMSKanbanExtendAppService( |
||||
|
|
||||
|
|
||||
|
IExcelImportAppService excelImportService, |
||||
|
|
||||
|
ISettleAccountBranchEfCoreRepository<WmsWithOutKanbanOutPutDetial, Guid> wmsRepository, |
||||
|
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
||||
|
ISettleAccountBranchEfCoreRepository<WmsWithOutKanbanOutPut, Guid> wmsVersionRepository, |
||||
|
WMSEfCoreRepository<WmsKanbanOutPutDetial> wmsefRespository, |
||||
|
KanbanUnSettledDapperRepository dapper, |
||||
|
WMSEfCoreRepository<TB_BILL> wmstbRespository, |
||||
|
IDistributedCache<WmsWithOutKanbanOutPutDetial> cache, |
||||
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
||||
|
ICommonManager commonManager, |
||||
|
WmsDapperRepository wmsDapper |
||||
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
||||
|
{ |
||||
|
_job = job; |
||||
|
_wmstbRespository = wmstbRespository; |
||||
|
_wmsRepository = wmsRepository; |
||||
|
_wmsVersionRepository = wmsVersionRepository; |
||||
|
_wmsefRespository = wmsefRespository; |
||||
|
_excelImportService = excelImportService; |
||||
|
_dapper = dapper; |
||||
|
_wmsDapper = wmsDapper; |
||||
|
} |
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsKanbanOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "BillNum", Logic = EnumFilterLogic.And, Value = input.BillNum }); |
||||
|
return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
||||
|
} |
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsKanbanOutPutRequestDto input) |
||||
|
{ |
||||
|
return await _wmsVersionRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库主表
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsWithOutKanbanOutPut>> GetListAsync(WmsKanbanOutPutRequestDto input) |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "BillNum", Logic = EnumFilterLogic.And, Value = input.BillNum }); |
||||
|
var entities = await _wmsVersionRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
return new PagedResultDto<WmsWithOutKanbanOutPut>(totalCount, entities); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanDetailList")] |
||||
|
[UnitOfWork(false)] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsWithOutKanbanOutPutDetial>> GetListAsync(WmsKanbanOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
var stockList = _wmsDapper.GetSalesStock(); |
||||
|
var query = from itm in entities |
||||
|
join itm1 in stockList on itm.SapMaterialCode equals itm1.SapCode |
||||
|
into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
select new WmsWithOutKanbanOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
"无看板发货", |
||||
|
itm.SapMaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.Version, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
itm.Qty, |
||||
|
tm1==null?0: tm1.Qty, |
||||
|
itm.OutputQty, |
||||
|
string.Empty, |
||||
|
itm.BillNum, |
||||
|
itm.State, |
||||
|
itm.RealityNumber |
||||
|
); |
||||
|
|
||||
|
return new PagedResultDto<WmsWithOutKanbanOutPutDetial>(totalCount, entities); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 任务明细标记已确认
|
||||
|
/// </summary>
|
||||
|
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartOutPutModify")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
|
||||
|
public async Task<bool> WmsSharePartUpdate(WmsWithOutKanbanOutPutDetial detial) |
||||
|
{ |
||||
|
var _entityList = _wmsRepository.Where(p => p.Id == detial.BranchId).ToList(); |
||||
|
if (_entityList.Count() > 0) |
||||
|
{ |
||||
|
foreach (var itm in _entityList) |
||||
|
{ |
||||
|
itm.OutputQty = detial.OutputQty; |
||||
|
await _wmsRepository.UpdateAsync(itm); |
||||
|
} |
||||
|
} |
||||
|
return true; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 选择任务,生成出库单,只包含已确认的单据
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPutExtend")] |
||||
|
[UnitOfWork(false)] |
||||
|
public async Task<string> WmsKanbanOutPut(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
var _list = _dapper.GetNoKanbanSettleDetail(input.Version); |
||||
|
var stockList = _wmsDapper.GetSalesStock(); |
||||
|
var query = from itm in _list |
||||
|
join itm1 in stockList on itm.SapMaterialCode equals itm1.SapCode |
||||
|
into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
select new WmsWithOutKanbanOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
"无看板发货", |
||||
|
itm.SapMaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.Version, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
itm.InvoiceQty, |
||||
|
tm1==null?0:tm1.Qty, |
||||
|
itm.InvoiceQty, |
||||
|
string.Empty, |
||||
|
_billNum, |
||||
|
0, |
||||
|
0 |
||||
|
); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(query.ToList(), new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); |
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
} |
||||
|
return ApplicationConsts.SuccessStr; ; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 出库界面功能,核准出库功能
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="p_list"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPut-Pass")] |
||||
|
[UnitOfWork(false)] |
||||
|
public async Task<bool> WmsKanbanOutPutPass(WmsJitRequestDto input) |
||||
|
{ |
||||
|
if (input.Guids != null) |
||||
|
{ |
||||
|
List<WmsWithOutKanbanOutPutDetial> _ls = new List<WmsWithOutKanbanOutPutDetial>(); |
||||
|
if (input.Guids.Count() > 0) |
||||
|
{ |
||||
|
_ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); |
||||
|
} |
||||
|
_ls = _ls.Where(p => p.SockQty >= p.OutputQty).ToList(); |
||||
|
if (_ls.Count() > 0) |
||||
|
{ |
||||
|
var sql = "DECLARE @return_value int\n" + |
||||
|
"EXEC @return_value = [dbo].[p_wms_output]\n" + |
||||
|
" @billnum = N'{0}',\n" + |
||||
|
" @type = 11,\n" + |
||||
|
" @date = N'{1}'\n" + |
||||
|
"SELECT 'Return Value' = @return_value"; |
||||
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
||||
|
string.Format(sql, input.BillNum, input.AccountDate.ToShortDateString())); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///出库界面功能, 撤销核准出库
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPut-Cancel")] |
||||
|
public async Task<bool> WmsKanbanOutPutCancel(WmsJitRequestDto input) |
||||
|
{ |
||||
|
if (input.Guids != null && input.Guids.Count() > 0) |
||||
|
{ |
||||
|
List<string> _ls = new List<string>(); |
||||
|
foreach (var itm in input.Guids) |
||||
|
{ |
||||
|
_ls.Add(string.Format("{0}", itm)); |
||||
|
} |
||||
|
|
||||
|
string str = string.Join(",", _ls.ToArray()); |
||||
|
|
||||
|
var sql = "DECLARE @return_value int\n" + |
||||
|
"EXEC @return_value = [dbo].[p_wms_output_cancel]\n" + |
||||
|
" @Guids ='{0}', \n" + |
||||
|
" @billnum = N'{1}',\n" + |
||||
|
" @type = 11,\n" + |
||||
|
" @accountdate = N'{2}'\n" + |
||||
|
"SELECT 'Return Value' = @return_value"; |
||||
|
|
||||
|
sql = string.Format(sql, str, input.BillNum, input.AccountDate.ToShortDateString()); |
||||
|
|
||||
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
||||
|
sql |
||||
|
); |
||||
|
|
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 出库界面功能删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="p_list"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsOutPutDelete")] |
||||
|
[UnitOfWork(false)] |
||||
|
public async Task<bool> WmsOutPutDelete(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); |
||||
|
|
||||
|
if (count > 0) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
var sql = "DECLARE @return_value int\n" + |
||||
|
"EXEC @return_value = [dbo].[p_wms_output_cancel_all]\n" + |
||||
|
" @billnum = N'{0}',\n" + |
||||
|
" @type = 11\n" + |
||||
|
"SELECT 'Return Value' = @return_value"; |
||||
|
await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( |
||||
|
string.Format(sql, input.BillNum) |
||||
|
); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// 物料 物料组 物料描述 物料号 开始日期 结束日期 单位 出库数量 结算数量 寄售库存数量
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue