44673626
3 years ago
43 changed files with 9680 additions and 899 deletions
Binary file not shown.
File diff suppressed because it is too large
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Reports.ReportRequestDto |
||||
|
{ |
||||
|
public class BaseRequestDto |
||||
|
{ |
||||
|
public string Version { set; get; } |
||||
|
public string MaterialCode { set; get; } |
||||
|
public string Begin { set; get; } |
||||
|
public string End { set; get; } |
||||
|
public string Cp7Begin { set; get; } |
||||
|
public string Cp7End { set; get; } |
||||
|
public string Kenncode { set; get; } |
||||
|
public string ChassisNumber { set; get; } |
||||
|
public string MaterialGroup { set; get; } |
||||
|
public string SapCode { set; get; } |
||||
|
} |
||||
|
public class BaseKanbanReqestDto |
||||
|
{ |
||||
|
public string KanBan {set;get;} |
||||
|
public string SapMaterialCode {set;get;} |
||||
|
public string Version {set;get;} |
||||
|
public string CustomerCode {set;get;} |
||||
|
public string CustomerPartCode {set;get;} |
||||
|
public string EstimateTypeDesc {set;get;} |
||||
|
public string State {set;get;} |
||||
|
public DateTime Begin {set;get;} |
||||
|
public DateTime End { set; get; } |
||||
|
|
||||
|
} |
||||
|
} |
@ -1,264 +0,0 @@ |
|||||
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; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 大众准时化结算明细导入-R3已结
|
|
||||
/// </summary>
|
|
||||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|
||||
[AllowAnonymous] |
|
||||
[Route("api/settleaccount/wms")] |
|
||||
public class WMSAppService : |
|
||||
ApplicationService |
|
||||
{ |
|
||||
|
|
||||
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> _wmsRepository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> _wmsVersionRepository; |
|
||||
private readonly WMSEfCoreRepository<WmsJitOutPutDetial> _wmsefRespository; |
|
||||
|
|
||||
private readonly WMSEfCoreRepository<TB_BILL> _wmstbRespository; |
|
||||
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job; |
|
||||
|
|
||||
private readonly TaskJobService _service; |
|
||||
/// <summary>
|
|
||||
/// 构建方法
|
|
||||
/// </summary>
|
|
||||
/// <param name="guidGenerator">构建UID</param>
|
|
||||
|
|
||||
/// <param name="repository">仓储接口</param>
|
|
||||
/// <param name="cache">缓存</param>
|
|
||||
public WMSAppService( |
|
||||
|
|
||||
ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> wmsRepository, |
|
||||
|
|
||||
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
|
||||
|
|
||||
ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> wmsVersionRepository, |
|
||||
WMSEfCoreRepository<WmsJitOutPutDetial> wmsefRespository, |
|
||||
WMSEfCoreRepository<TB_BILL> wmstbRespository |
|
||||
) |
|
||||
{ |
|
||||
_job = job; |
|
||||
_wmstbRespository = wmstbRespository; |
|
||||
_wmsRepository = wmsRepository; |
|
||||
_wmsVersionRepository = wmsVersionRepository; |
|
||||
_wmsefRespository = wmsefRespository; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 选择结算明细任务列表,选择相关任务合拼导期间出库表
|
|
||||
/// </summary>
|
|
||||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|
||||
/// <returns></returns>
|
|
||||
[HttpGet] |
|
||||
[Route("WmsJitOutPut")] |
|
||||
[DisableRequestSizeLimit] |
|
||||
|
|
||||
public async Task<string> WmsJitOutPut(List<Guid> ids, string version) |
|
||||
{ |
|
||||
|
|
||||
var _joblist=_job.Where(p => ids.Contains(p.Id)).ToList(); |
|
||||
|
|
||||
|
|
||||
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); |
|
||||
|
|
||||
List<WmsJitOutPutDetial> _lst = new List<WmsJitOutPutDetial>(); |
|
||||
foreach (var filename in fileList) |
|
||||
{ |
|
||||
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; |
|
||||
IExcelImporter Importer = new Magicodes.ExporterAndImporter.Excel.ExcelImporter(); |
|
||||
var _list = await Importer.ImportSameSheets<WmsJitOutPutDetialDto, WmsJitOutPutDetial>(fileSavePath); |
|
||||
foreach (var itm in _list) |
|
||||
{ |
|
||||
var list = itm.Value.Data.ToList(); |
|
||||
_lst.AddRange(list.ToArray()); |
|
||||
} |
|
||||
} |
|
||||
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
|
||||
|
|
||||
|
|
||||
var outPutDetail= await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
|
||||
|
|
||||
|
|
||||
var _billNum="T" + DateTime.Now.ToString("yyyyMMddhhmmssdddd"); |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
var query = from itm1 in _ls1 |
|
||||
join itm2 in outPutDetail on |
|
||||
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber } |
|
||||
equals |
|
||||
new { itm2.MaterialCode, itm2.KennCode, itm2.ChassisNumber } into temp1 |
|
||||
from tm1 in temp1.DefaultIfEmpty() where tm1==null |
|
||||
select itm1; |
|
||||
|
|
||||
|
|
||||
var _wmslst=query.ToList(); |
|
||||
foreach (var itm in _wmslst) |
|
||||
{ |
|
||||
itm.BillNum = _billNum; |
|
||||
} |
|
||||
|
|
||||
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0 }); |
|
||||
int _count= _wmsVersionRepository.Count(p => p.Version == version); |
|
||||
if (_count == 0) |
|
||||
{ |
|
||||
var _version = new List<WmsJitOutPut>(); |
|
||||
_version.Add(new WmsJitOutPut { Version = version, BillNum = _billNum, Creator = CurrentUser.Email }); |
|
||||
await _wmsVersionRepository.GetDbContext().BulkInsertAsync(_version); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
var _ls= _wmsVersionRepository.Where(p => p.Version == version).ToList(); |
|
||||
foreach (var itm in _ls) |
|
||||
{ |
|
||||
itm.BillNum = _billNum; |
|
||||
} |
|
||||
await _wmsVersionRepository.UpdateManyAsync(_ls); |
|
||||
} |
|
||||
//_wmsRepository.Where(p=>p)
|
|
||||
|
|
||||
return _billNum; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
[Route("WmsJitOutPut-Pass")] |
|
||||
|
|
||||
public async Task<bool> WmsJitOutPutPass( string version, List<Guid> p_list=null) |
|
||||
{ |
|
||||
if (p_list != null) |
|
||||
{ |
|
||||
List<WmsJitOutPutDetial> _ls = new List<WmsJitOutPutDetial>(); |
|
||||
if (p_list.Count() > 0) |
|
||||
{ |
|
||||
_ls = await _wmsRepository.Where(p => p_list.Contains(p.Id) && p.Version == version && p.State != 2).ToListAsync(); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_ls = await _wmsRepository.Where(p => p.Version == version && p.State != 2).ToListAsync(); |
|
||||
} |
|
||||
if (_ls.Count() > 0) |
|
||||
{ |
|
||||
var _first = _ls.FirstOrDefault(); |
|
||||
var _guid = GuidGenerator.Create(); |
|
||||
foreach (var itm in _ls) |
|
||||
{ |
|
||||
itm.TaskId = _guid; |
|
||||
} |
|
||||
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls); |
|
||||
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail",_first.BillNum, 0,0 ,_guid) |
|
||||
{ |
|
||||
TaskId = _guid, |
|
||||
SourceBillNum = _first.BillNum, |
|
||||
TableName = "WmsJitOutPutDetail", |
|
||||
InterfaceType = "1", |
|
||||
Version = version, |
|
||||
SettleAccountState = 0, |
|
||||
WmsState=0 |
|
||||
|
|
||||
}; |
|
||||
var _l = new List<TS_UNI_API>(); |
|
||||
_l.Add(uniapi); |
|
||||
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
//_wmsDapper.GetListBySql<WmsJitOutPutDetial>("insert into WmsJitOutPutDetial", false);
|
|
||||
//_wmsDapper.DbConnection.ConnectionTimeout = 1200;
|
|
||||
//_wmsRepository.Where(p=>p)
|
|
||||
return true; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
[HttpGet] |
|
||||
[Route("WmsJitOutPut-Cancel")] |
|
||||
|
|
||||
public async Task<bool> WmsJitOutPutCancel(List<Guid> ids, string version) |
|
||||
{ |
|
||||
|
|
||||
//var _guid = GuidGenerator.Create();
|
|
||||
//foreach (var itm in _ls)
|
|
||||
//{
|
|
||||
// itm.TaskId = _guid;
|
|
||||
//}
|
|
||||
var _ls = await _wmsRepository.Where(p => ids.Contains(p.Id) && p.Version == version && p.State == 1).ToListAsync(); |
|
||||
var _first = _ls.FirstOrDefault(); |
|
||||
if (_ls.Count>0) |
|
||||
{ |
|
||||
var _guid = GuidGenerator.Create(); |
|
||||
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls,new BulkConfig() { BulkCopyTimeout=0 }); |
|
||||
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail", _first.BillNum, 0,0, _guid) |
|
||||
{ |
|
||||
TaskId = _guid, |
|
||||
SourceBillNum = _first.BillNum, |
|
||||
TableName = "WmsJitOutPutDetail", |
|
||||
InterfaceType = "1", |
|
||||
Version = version, |
|
||||
WmsState = 0, |
|
||||
SettleAccountState=0 |
|
||||
}; |
|
||||
var _l = new List<TS_UNI_API>(); |
|
||||
_l.Add(uniapi); |
|
||||
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
|
||||
|
|
||||
} |
|
||||
return true; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
} |
|
@ -0,0 +1,458 @@ |
|||||
|
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; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// wms出库
|
||||
|
/// </summary>
|
||||
|
|
||||
|
[AllowAnonymous] |
||||
|
[Route("api/settleaccount/wmsjitoutput")] |
||||
|
public class WMSJitAppService : |
||||
|
ApplicationService |
||||
|
{ |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> _wmsRepository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> _wmsVersionRepository; |
||||
|
private readonly WMSEfCoreRepository<WmsJitOutPutDetial> _wmsefRespository; |
||||
|
private readonly WMSEfCoreRepository<TB_BILL> _wmstbRespository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job; |
||||
|
private readonly IExcelImportAppService _excelImportService; |
||||
|
private readonly TaskJobService _service; |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="wmsRepository"></param>
|
||||
|
/// <param name="job"></param>
|
||||
|
/// <param name="wmsVersionRepository"></param>
|
||||
|
/// <param name="wmsefRespository"></param>
|
||||
|
/// <param name="wmstbRespository"></param>
|
||||
|
public WMSJitAppService( |
||||
|
IExcelImportAppService excelImportService, |
||||
|
ISettleAccountBranchEfCoreRepository<WmsJitOutPutDetial, Guid> wmsRepository, |
||||
|
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
||||
|
ISettleAccountBranchEfCoreRepository<WmsJitOutPut, Guid> wmsVersionRepository, |
||||
|
WMSEfCoreRepository<WmsJitOutPutDetial> wmsefRespository, |
||||
|
WMSEfCoreRepository<TB_BILL> wmstbRespository |
||||
|
) |
||||
|
{ |
||||
|
_job = job; |
||||
|
_wmstbRespository = wmstbRespository; |
||||
|
_wmsRepository = wmsRepository; |
||||
|
_wmsVersionRepository = wmsVersionRepository; |
||||
|
_wmsefRespository = wmsefRespository; |
||||
|
_excelImportService = excelImportService; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("ExcelImport")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files, string version) |
||||
|
{ |
||||
|
var _billNum = "T" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
ExportImporter _exportImporter = new ExportImporter(); |
||||
|
var result = await _exportImporter.ExtendExcelImport<WmsJitOutPutDetial>(files, _excelImportService); |
||||
|
List<WmsJitOutPutDetial> _lst = new List<WmsJitOutPutDetial>(); |
||||
|
var _lsCopy = new List<WmsJitOutPutDetial>(); |
||||
|
foreach (var itm in result) |
||||
|
{ |
||||
|
WmsJitOutPutDetial _detail = new WmsJitOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
itm.WmsBillNum, |
||||
|
itm.KennCode, |
||||
|
itm.ChassisNumber, |
||||
|
itm.MaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.MaterialGroup, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
0, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
version, |
||||
|
itm.ParentMaterialCode, |
||||
|
itm.BillNum, |
||||
|
GuidGenerator.Create() |
||||
|
, string.Empty |
||||
|
, itm.Qty |
||||
|
); |
||||
|
_lsCopy.Add(_detail); |
||||
|
} |
||||
|
_lst.AddRange(_lsCopy.ToArray()); |
||||
|
|
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.KennCode, itm2.ChassisNumber } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsJitOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); |
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsJitOutPutDetialRequestDto 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(WmsJitOutPutRequestDto input) |
||||
|
{ |
||||
|
return await _wmsVersionRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库主表
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsJitOutPut>> GetListAsync(WmsJitOutPutRequestDto input) |
||||
|
{ |
||||
|
|
||||
|
var entities = await _wmsVersionRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
|
||||
|
|
||||
|
return new PagedResultDto<WmsJitOutPut>(totalCount, entities); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitDetailList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsJitOutPutDetial>> GetListAsync(WmsJitOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
|
||||
|
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "BillNum", Logic = EnumFilterLogic.And, Value = input.BillNum }); |
||||
|
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
//var dtoDetails = ObjectMapper.Map<List<WmsJitOutPutDetial>, List<WmsJitOutPutDetialDto>>(entities);
|
||||
|
|
||||
|
return new PagedResultDto<WmsJitOutPutDetial>(totalCount, entities); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 任务明细标记已确认
|
||||
|
/// </summary>
|
||||
|
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitOutPutAudit")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
|
||||
|
public async Task<bool> WmsJitAudit(List<Guid> ids) |
||||
|
{ |
||||
|
var _joblist = await _job.Where(p => ids.Contains(p.Id)).ToListAsync(); |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
itm.FileName = "已确认"; |
||||
|
await _job.UpdateAsync(itm); |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 任务明细标记已确认
|
||||
|
/// </summary>
|
||||
|
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitOutPutCancel")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
|
||||
|
public async Task<bool> WmsJitCancel(List<Guid> ids) |
||||
|
{ |
||||
|
var _joblist = await _job.Where(p => ids.Contains(p.Id) && p.FileName == "已确认").ToListAsync(); |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
itm.FileName = "取消确认"; |
||||
|
await _job.UpdateAsync(itm); |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 选择任务,生成出库单,只包含已确认的单据
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitOutPut")] |
||||
|
public async Task<string> WmsJitOutPut(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _billNum = "T" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); |
||||
|
if (_joblist.Count() > 0) |
||||
|
{ |
||||
|
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); |
||||
|
List<WmsJitOutPutDetial> _lst = new List<WmsJitOutPutDetial>(); |
||||
|
foreach (var filename in fileList) |
||||
|
{ |
||||
|
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; |
||||
|
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); |
||||
|
var _list = _excelHelper.ExcelToList<WmsJitOutPutDetial>(); |
||||
|
var _lsCopy = new List<WmsJitOutPutDetial>(); |
||||
|
foreach (var itm in _list) |
||||
|
{ |
||||
|
WmsJitOutPutDetial _detail = new WmsJitOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
itm.WmsBillNum, |
||||
|
itm.KennCode, |
||||
|
itm.ChassisNumber, |
||||
|
itm.MaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.MaterialGroup, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
0, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
input.Version, |
||||
|
itm.ParentMaterialCode, |
||||
|
itm.BillNum, |
||||
|
GuidGenerator.Create() |
||||
|
, string.Empty |
||||
|
, itm.Qty |
||||
|
); |
||||
|
_lsCopy.Add(_detail); |
||||
|
} |
||||
|
_lst.AddRange(_lsCopy.ToArray()); |
||||
|
} |
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); |
||||
|
|
||||
|
var error = from itm1 in outPutDetail |
||||
|
join itm2 in _ls1 on |
||||
|
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.KennCode, itm2.ChassisNumber } |
||||
|
select itm1; |
||||
|
var errList= error.GroupBy(p => new { p.BillNum }).Select(p => new {BillNum=p.Key.BillNum,Number=p.Sum(itm=>itm.Qty) }); |
||||
|
if (errList.Count() == 0) |
||||
|
{ |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.KennCode, itm1.ChassisNumber } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.KennCode, itm2.ChassisNumber } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsJitOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); |
||||
|
//var _ls = new List<WmsJitOutPut>();
|
||||
|
//_ls.Add(_version);
|
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
} |
||||
|
foreach (var job in _joblist) |
||||
|
{ |
||||
|
job.FileName = _billNum; |
||||
|
await _job.UpdateAsync(job); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
StringBuilder _buffer = new StringBuilder(); |
||||
|
foreach (var itm in errList) |
||||
|
{ |
||||
|
_buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); |
||||
|
} |
||||
|
var _errinfo= _buffer.ToString(); |
||||
|
|
||||
|
foreach (var job in _joblist) |
||||
|
{ |
||||
|
job.FileName =_errinfo; |
||||
|
await _job.UpdateAsync(job); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_billNum = string.Empty; |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 出库界面功能,核准出库功能
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="p_list"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitOutPut-Pass")] |
||||
|
public async Task<bool> WmsJitOutPutPass(WmsJitRequestDto input) |
||||
|
{ |
||||
|
if (input.Guids != null) |
||||
|
{ |
||||
|
List<WmsJitOutPutDetial> _ls = new List<WmsJitOutPutDetial>(); |
||||
|
if (input.Guids.Count() > 0) |
||||
|
{ |
||||
|
_ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State != 2).ToListAsync(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); |
||||
|
} |
||||
|
if (_ls.Count() > 0) |
||||
|
{ |
||||
|
foreach (var itm in _ls) |
||||
|
{ |
||||
|
itm.State = 1; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkUpdateAsync(_ls); |
||||
|
//var _first = _ls.FirstOrDefault();
|
||||
|
//var _guid = GuidGenerator.Create();
|
||||
|
//foreach (var itm in _ls)
|
||||
|
//{
|
||||
|
// itm.TaskId = _guid;
|
||||
|
//}
|
||||
|
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls);
|
||||
|
//var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail",_first.BillNum, 0,0 ,_guid)
|
||||
|
//{
|
||||
|
// TaskId = _guid,
|
||||
|
// SourceBillNum = _first.BillNum,
|
||||
|
// TableName = "WmsJitOutPutDetail",
|
||||
|
// InterfaceType = "1",
|
||||
|
// Version = version,
|
||||
|
// SettleAccountState = 0,
|
||||
|
// WmsState=0
|
||||
|
|
||||
|
//};
|
||||
|
//var _l = new List<TS_UNI_API>();
|
||||
|
//_l.Add(uniapi);
|
||||
|
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///出库界面功能, 撤销核准出库
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsJitOutPut-Cancel")] |
||||
|
public async Task<bool> WmsJitOutPutCancel(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State == 2).ToListAsync(); |
||||
|
var _first = _ls.FirstOrDefault(); |
||||
|
if (_ls.Count > 0) |
||||
|
{ |
||||
|
//var _guid = GuidGenerator.Create();
|
||||
|
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls,new BulkConfig() { BulkCopyTimeout=0 });
|
||||
|
//var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", version, "WmsJitOutPutDetail", _first.BillNum, 0,0, _guid)
|
||||
|
//{
|
||||
|
// TaskId = _guid,
|
||||
|
// SourceBillNum = _first.BillNum,
|
||||
|
// TableName = "WmsJitOutPutDetail",
|
||||
|
// InterfaceType = "1",
|
||||
|
// Version = version,
|
||||
|
// WmsState = 0,
|
||||
|
// SettleAccountState=0
|
||||
|
//};
|
||||
|
//var _l = new List<TS_UNI_API>();
|
||||
|
//_l.Add(uniapi);
|
||||
|
//await _wmsefRespository.GetDbContext().BulkInsertAsync(_l);
|
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,381 @@ |
|||||
|
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; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// wms出库
|
||||
|
/// </summary>
|
||||
|
|
||||
|
[AllowAnonymous] |
||||
|
[Route("api/settleaccount/wmskanbanoutput")] |
||||
|
public class WMSKanbanAppService : |
||||
|
ApplicationService |
||||
|
{ |
||||
|
|
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsKanbanOutPutDetial, Guid> _wmsRepository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsKanbanOutPut, Guid> _wmsVersionRepository; |
||||
|
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; |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="wmsRepository"></param>
|
||||
|
/// <param name="job"></param>
|
||||
|
/// <param name="wmsVersionRepository"></param>
|
||||
|
/// <param name="wmsefRespository"></param>
|
||||
|
/// <param name="wmstbRespository"></param>
|
||||
|
public WMSKanbanAppService( |
||||
|
|
||||
|
|
||||
|
IExcelImportAppService excelImportService, |
||||
|
|
||||
|
ISettleAccountBranchEfCoreRepository<WmsKanbanOutPutDetial, Guid> wmsRepository, |
||||
|
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
||||
|
ISettleAccountBranchEfCoreRepository<WmsKanbanOutPut, Guid> wmsVersionRepository, |
||||
|
WMSEfCoreRepository<WmsKanbanOutPutDetial> wmsefRespository, |
||||
|
WMSEfCoreRepository<TB_BILL> wmstbRespository |
||||
|
) |
||||
|
{ |
||||
|
_job = job; |
||||
|
_wmstbRespository = wmstbRespository; |
||||
|
_wmsRepository = wmsRepository; |
||||
|
_wmsVersionRepository = wmsVersionRepository; |
||||
|
_wmsefRespository = wmsefRespository; |
||||
|
_excelImportService = excelImportService; |
||||
|
} |
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsKanbanOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
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<WmsKanbanOutPut>> GetListAsync( WmsKanbanOutPutRequestDto input) |
||||
|
{ |
||||
|
|
||||
|
var entities = await _wmsVersionRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
|
||||
|
|
||||
|
return new PagedResultDto<WmsKanbanOutPut>(totalCount, entities); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanDetailList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsKanbanOutPutDetial>> GetListAsync(WmsKanbanOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
return new PagedResultDto<WmsKanbanOutPutDetial>(totalCount, entities); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 任务明细标记已确认
|
||||
|
/// </summary>
|
||||
|
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPutAudit")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
|
||||
|
public async Task<bool> WmsKanbanAudit(List<Guid> ids) |
||||
|
{ |
||||
|
var _joblist =await _job.Where(p => ids.Contains(p.Id)).ToListAsync(); |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
itm.FileName = "已确认"; |
||||
|
} |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
await _job.UpdateAsync(itm); |
||||
|
} |
||||
|
var _count=await _job.BatchUpdateAsync(_joblist.ToList()); |
||||
|
if (_count > 0) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 选择任务,生成出库单,只包含已确认的单据
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPut")] |
||||
|
public async Task<string> WmsKanbanOutPut(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _billNum = "K" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
|
||||
|
var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); |
||||
|
if (_joblist.Count() > 0) |
||||
|
{ |
||||
|
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); |
||||
|
List<WmsKanbanOutPutDetial> _lst = new List<WmsKanbanOutPutDetial>(); |
||||
|
foreach (var filename in fileList) |
||||
|
{ |
||||
|
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; |
||||
|
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); |
||||
|
var _list = _excelHelper.ExcelToList<WmsKanbanOutPutDetial>(); |
||||
|
foreach (var itm in _list) |
||||
|
{ |
||||
|
itm.SetId(GuidGenerator.Create()); |
||||
|
} |
||||
|
_lst.AddRange(_list.ToArray()); |
||||
|
} |
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.Kanban } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.Kanban } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); |
||||
|
|
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
foreach (var job in _joblist) |
||||
|
{ |
||||
|
job.FileName = _billNum; |
||||
|
await _job.UpdateAsync(job); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_billNum = string.Empty; |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 出库界面功能,核准出库功能
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="p_list"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsKanbanOutPut-Pass")] |
||||
|
public async Task<bool> WmsKanbanOutPutPass(WmsJitRequestDto input) |
||||
|
{ |
||||
|
if (input.Guids != null) |
||||
|
{ |
||||
|
List<WmsKanbanOutPutDetial> _ls = new List<WmsKanbanOutPutDetial>(); |
||||
|
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(); |
||||
|
} |
||||
|
if (_ls.Count() > 0) |
||||
|
{ |
||||
|
var _first = _ls.FirstOrDefault(); |
||||
|
var _guid = GuidGenerator.Create(); |
||||
|
foreach (var itm in _ls) |
||||
|
{ |
||||
|
itm.TaskId = _guid; |
||||
|
} |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls); |
||||
|
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsKanbanOutPutDetail",_first.BillNum, 0,0 ,_guid) |
||||
|
{ |
||||
|
TaskId = _guid, |
||||
|
SourceBillNum = _first.BillNum, |
||||
|
TableName = "WmsKanbanOutPutDetail", |
||||
|
InterfaceType = "2", |
||||
|
Version = input.Version, |
||||
|
SettleAccountState = 0, |
||||
|
WmsState=0 |
||||
|
}; |
||||
|
var _l = new List<TS_UNI_API>(); |
||||
|
_l.Add(uniapi); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
||||
|
} |
||||
|
} |
||||
|
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) |
||||
|
{ |
||||
|
var _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State == 1).ToListAsync(); |
||||
|
var _first = _ls.FirstOrDefault(); |
||||
|
if (_ls.Count()>0) |
||||
|
{ |
||||
|
var _guid = GuidGenerator.Create(); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls,new BulkConfig() { BulkCopyTimeout=0 }); |
||||
|
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsKanbanOutPutDetail", _first.BillNum, 0,0, _guid) |
||||
|
{ |
||||
|
TaskId = _guid, |
||||
|
SourceBillNum = _first.BillNum, |
||||
|
TableName = "WmsKanbanOutPutDetail", |
||||
|
InterfaceType = "2", |
||||
|
Version = input.Version, |
||||
|
WmsState = 0, |
||||
|
SettleAccountState=0 |
||||
|
}; |
||||
|
var _l = new List<TS_UNI_API>(); |
||||
|
_l.Add(uniapi); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
[HttpPost] |
||||
|
[Route("ExcelImport")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files, string version) |
||||
|
{ |
||||
|
var _billNum = "K" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
ExportImporter _exportImporter = new ExportImporter(); |
||||
|
var result = await _exportImporter.ExtendExcelImport<WmsKanbanOutPutDetial>(files, _excelImportService); |
||||
|
List<WmsKanbanOutPutDetial> _lst = new List<WmsKanbanOutPutDetial>(); |
||||
|
var _lsCopy = new List<WmsKanbanOutPutDetial>(); |
||||
|
foreach (var itm in result) |
||||
|
{ |
||||
|
WmsKanbanOutPutDetial _detail = new WmsKanbanOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
itm.WmsBillNum, |
||||
|
itm.Kanban, |
||||
|
|
||||
|
itm.MaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.MaterialGroup, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
0, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
version, |
||||
|
itm.ParentMaterialCode, |
||||
|
itm.BillNum, |
||||
|
GuidGenerator.Create() |
||||
|
, string.Empty |
||||
|
, itm.Qty.Value |
||||
|
); |
||||
|
_lsCopy.Add(_detail); |
||||
|
} |
||||
|
_lst.AddRange(_lsCopy.ToArray()); |
||||
|
|
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.Kanban } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.Kanban } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); |
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,382 @@ |
|||||
|
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; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// wms出库
|
||||
|
/// </summary>
|
||||
|
|
||||
|
[AllowAnonymous] |
||||
|
[Route("api/settleaccount/wmsSharePartoutput")] |
||||
|
public class WMSSharePartAppService : |
||||
|
ApplicationService |
||||
|
{ |
||||
|
|
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsSharePartOutPutDetial, Guid> _wmsRepository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<WmsSharePartOutPut, Guid> _wmsVersionRepository; |
||||
|
private readonly WMSEfCoreRepository<WmsSharePartOutPutDetial> _wmsefRespository; |
||||
|
|
||||
|
private readonly WMSEfCoreRepository<TB_BILL> _wmstbRespository; |
||||
|
private readonly ISettleAccountBranchEfCoreRepository<TaskJob, Guid> _job; |
||||
|
private readonly IExcelImportAppService _excelImportService; |
||||
|
|
||||
|
private readonly TaskJobService _service; |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="wmsRepository"></param>
|
||||
|
/// <param name="job"></param>
|
||||
|
/// <param name="wmsVersionRepository"></param>
|
||||
|
/// <param name="wmsefRespository"></param>
|
||||
|
/// <param name="wmstbRespository"></param>
|
||||
|
public WMSSharePartAppService( |
||||
|
|
||||
|
ISettleAccountBranchEfCoreRepository<WmsSharePartOutPutDetial, Guid> wmsRepository, |
||||
|
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
||||
|
ISettleAccountBranchEfCoreRepository<WmsSharePartOutPut, Guid> wmsVersionRepository, |
||||
|
WMSEfCoreRepository<WmsSharePartOutPutDetial> wmsefRespository, |
||||
|
WMSEfCoreRepository<TB_BILL> wmstbRespository, |
||||
|
IExcelImportAppService excelImportService |
||||
|
) |
||||
|
{ |
||||
|
_excelImportService = excelImportService; |
||||
|
_job = job; |
||||
|
_wmstbRespository = wmstbRespository; |
||||
|
_wmsRepository = wmsRepository; |
||||
|
_wmsVersionRepository = wmsVersionRepository; |
||||
|
_wmsefRespository = wmsefRespository; |
||||
|
} |
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsSharePartOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
||||
|
} |
||||
|
|
||||
|
private async Task<long> GetCountAsync(WmsSharePartOutPutRequestDto input) |
||||
|
{ |
||||
|
return await _wmsVersionRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库主表
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsSharePartOutPut>> GetListAsync( WmsSharePartOutPutRequestDto input) |
||||
|
{ |
||||
|
|
||||
|
var entities = await _wmsVersionRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
|
||||
|
|
||||
|
return new PagedResultDto<WmsSharePartOutPut>(totalCount, entities); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 准时化出库明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartDetailList")] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
virtual public async Task<PagedResultDto<WmsSharePartOutPutDetial>> GetListAsync(WmsSharePartOutPutDetialRequestDto input) |
||||
|
{ |
||||
|
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
||||
|
input.SkipCount, true); |
||||
|
|
||||
|
var totalCount = await GetCountAsync(input); |
||||
|
return new PagedResultDto<WmsSharePartOutPutDetial>(totalCount, entities); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 任务明细标记已确认
|
||||
|
/// </summary>
|
||||
|
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartOutPutAudit")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
|
||||
|
public async Task<bool> WmsSharePartAudit(List<Guid> ids) |
||||
|
{ |
||||
|
var _joblist =await _job.Where(p => ids.Contains(p.Id)).ToListAsync(); |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
itm.FileName = "已确认"; |
||||
|
} |
||||
|
foreach (var itm in _joblist) |
||||
|
{ |
||||
|
await _job.UpdateAsync(itm); |
||||
|
} |
||||
|
var _count=await _job.BatchUpdateAsync(_joblist.ToList()); |
||||
|
if (_count > 0) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 选择任务,生成出库单,只包含已确认的单据
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartOutPut")] |
||||
|
|
||||
|
|
||||
|
public async Task<string> WmsSharePartOutPut(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
|
||||
|
var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); |
||||
|
if (_joblist.Count() > 0) |
||||
|
{ |
||||
|
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); |
||||
|
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); |
||||
|
foreach (var filename in fileList) |
||||
|
{ |
||||
|
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; |
||||
|
ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); |
||||
|
var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>(); |
||||
|
foreach (var itm in _list) |
||||
|
{ |
||||
|
itm.SetId(GuidGenerator.Create()); |
||||
|
} |
||||
|
_lst.AddRange(_list.ToArray()); |
||||
|
} |
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.OrderBillNum } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); |
||||
|
//var _ls = new List<WmsSharePartOutPut>();
|
||||
|
//_ls.Add(_version);
|
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
foreach (var job in _joblist) |
||||
|
{ |
||||
|
job.FileName = _billNum; |
||||
|
await _job.UpdateAsync(job); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_billNum = string.Empty; |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 出库界面功能,核准出库功能
|
||||
|
/// </summary>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <param name="p_list"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartOutPut-Pass")] |
||||
|
public async Task<bool> WmsSharePartOutPutPass(WmsJitRequestDto input) |
||||
|
{ |
||||
|
if (input.Guids != null) |
||||
|
{ |
||||
|
List<WmsSharePartOutPutDetial> _ls = new List<WmsSharePartOutPutDetial>(); |
||||
|
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(); |
||||
|
} |
||||
|
if (_ls.Count() > 0) |
||||
|
{ |
||||
|
var _first = _ls.FirstOrDefault(); |
||||
|
var _guid = GuidGenerator.Create(); |
||||
|
foreach (var itm in _ls) |
||||
|
{ |
||||
|
itm.TaskId = _guid; |
||||
|
} |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls); |
||||
|
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsSharePartOutPutDetail",_first.BillNum, 0,0 ,_guid) |
||||
|
{ |
||||
|
TaskId = _guid, |
||||
|
SourceBillNum = _first.BillNum, |
||||
|
TableName = "WmsSharePartOutPutDetail", |
||||
|
InterfaceType = "3", |
||||
|
Version = input.Version, |
||||
|
SettleAccountState = 0, |
||||
|
WmsState=0 |
||||
|
}; |
||||
|
var _l = new List<TS_UNI_API>(); |
||||
|
_l.Add(uniapi); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
||||
|
} |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///出库界面功能, 撤销核准出库
|
||||
|
/// </summary>
|
||||
|
/// <param name="ids"></param>
|
||||
|
/// <param name="version"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
[Route("WmsSharePartOutPut-Cancel")] |
||||
|
public async Task<bool> WmsSharePartOutPutCancel(WmsJitRequestDto input) |
||||
|
{ |
||||
|
var _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.State == 1).ToListAsync(); |
||||
|
var _first = _ls.FirstOrDefault(); |
||||
|
if (_ls.Count()>0) |
||||
|
{ |
||||
|
var _guid = GuidGenerator.Create(); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_ls,new BulkConfig() { BulkCopyTimeout=0 }); |
||||
|
var uniapi = new TS_UNI_API(GuidGenerator.Create(), "1", input.Version, "WmsSharePartOutPutDetail", _first.BillNum, 0,0, _guid) |
||||
|
{ |
||||
|
TaskId = _guid, |
||||
|
SourceBillNum = _first.BillNum, |
||||
|
TableName = "WmsSharePartOutPutDetail", |
||||
|
InterfaceType = "3", |
||||
|
Version = input.Version, |
||||
|
WmsState = 0, |
||||
|
SettleAccountState=0 |
||||
|
}; |
||||
|
var _l = new List<TS_UNI_API>(); |
||||
|
_l.Add(uniapi); |
||||
|
await _wmsefRespository.GetDbContext().BulkInsertAsync(_l); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
[HttpPost] |
||||
|
[Route("ExcelImport")] |
||||
|
[DisableRequestSizeLimit] |
||||
|
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
||||
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files, string version) |
||||
|
{ |
||||
|
var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); |
||||
|
ExportImporter _exportImporter = new ExportImporter(); |
||||
|
var result = await _exportImporter.ExtendExcelImport<WmsSharePartOutPutDetial>(files, _excelImportService); |
||||
|
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); |
||||
|
var _lsCopy = new List<WmsSharePartOutPutDetial>(); |
||||
|
foreach (var itm in result) |
||||
|
{ |
||||
|
WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( |
||||
|
GuidGenerator.Create(), |
||||
|
itm.WmsBillNum, |
||||
|
itm.OrderBillNum, |
||||
|
|
||||
|
itm.MaterialCode, |
||||
|
itm.MaterialDesc, |
||||
|
itm.MaterialGroup, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
0, |
||||
|
string.Empty, |
||||
|
string.Empty, |
||||
|
version, |
||||
|
itm.ParentMaterialCode, |
||||
|
itm.BillNum, |
||||
|
GuidGenerator.Create() |
||||
|
, string.Empty |
||||
|
, itm.Qty.Value |
||||
|
); |
||||
|
_lsCopy.Add(_detail); |
||||
|
} |
||||
|
_lst.AddRange(_lsCopy.ToArray()); |
||||
|
|
||||
|
var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); |
||||
|
var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); |
||||
|
var query = from itm1 in _ls1 |
||||
|
join itm2 in outPutDetail on |
||||
|
new { itm1.MaterialCode, itm1.OrderBillNum } |
||||
|
equals |
||||
|
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 |
||||
|
from tm1 in temp1.DefaultIfEmpty() |
||||
|
where tm1 == null |
||||
|
select itm1; |
||||
|
var _wmslst = query.ToList(); |
||||
|
foreach (var itm in _wmslst) |
||||
|
{ |
||||
|
itm.BillNum = _billNum; |
||||
|
} |
||||
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); |
||||
|
int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); |
||||
|
if (_count == 0) |
||||
|
{ |
||||
|
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); |
||||
|
await _wmsVersionRepository.InsertAsync(_version, true); |
||||
|
} |
||||
|
return _billNum; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,78 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 任务订阅表
|
||||
|
/// </summary>
|
||||
|
[Description("任务订阅表")] |
||||
|
public class TEA_TASK_SUB |
||||
|
{ |
||||
|
[Description("任务状态")] |
||||
|
public int TaskState { get; set; } |
||||
|
|
||||
|
|
||||
|
[Description("任务编号")] |
||||
|
public Guid TaskID { get; set; } |
||||
|
|
||||
|
[Description("表格名称")] |
||||
|
[StringLength(50)] |
||||
|
public string TableName { get; set; } |
||||
|
|
||||
|
[Description("创建者")] |
||||
|
[StringLength(50)] |
||||
|
public string Creator { get; set; } |
||||
|
|
||||
|
[Description("数据行数")] |
||||
|
public int DataCount { get; set; } |
||||
|
|
||||
|
|
||||
|
[Description("订阅者")] |
||||
|
[StringLength(50)] |
||||
|
public string Subscriber { get; set; } |
||||
|
|
||||
|
[Description("失败行数")] |
||||
|
public int FailedCount { get; set; } |
||||
|
|
||||
|
[Description("失败信息")] |
||||
|
[StringLength(50)] |
||||
|
public string FailedInfo { get; set; } |
||||
|
|
||||
|
[Description("域")] |
||||
|
[StringLength(50)] |
||||
|
public string Domain { get; set; } |
||||
|
|
||||
|
[Description("地点")] |
||||
|
[StringLength(50)] |
||||
|
public string Site { get; set; } |
||||
|
|
||||
|
[Key] |
||||
|
public Guid GUID { get; set; } = Guid.NewGuid(); |
||||
|
|
||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
||||
|
public int UID { get; set; } |
||||
|
|
||||
|
[Description("创建人")] |
||||
|
[StringLength(50)] |
||||
|
public string CreateUser { get; set; } |
||||
|
|
||||
|
[Description("创建时间")] |
||||
|
public DateTime CreateTime { get; set; } |
||||
|
|
||||
|
[Description("备注")] |
||||
|
public string Remark { get; set; } |
||||
|
|
||||
|
[Description("修改人")] |
||||
|
[StringLength(50)] |
||||
|
public string UpdateUser { get; set; } |
||||
|
|
||||
|
[Description("修改时间")] |
||||
|
public DateTime? UpdateTime { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Win.Sfs.Shared.DomainBase; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.WMS_KanBan |
||||
|
{ |
||||
|
public class WmsKanban: FullAuditedAggregateRootBase<Guid> |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 实际发货日期
|
||||
|
/// </summary>
|
||||
|
public DateTime BeginTime { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public string Version { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 零件号
|
||||
|
/// </summary>
|
||||
|
public string MaterialCode { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 用量
|
||||
|
/// </summary>
|
||||
|
public decimal Qty { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
Binary file not shown.
Loading…
Reference in new issue