diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs new file mode 100644 index 00000000..aaa608e1 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs @@ -0,0 +1,425 @@ +using EFCore.BulkExtensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.Entities.Wms; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.SettleAccount.Repository; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; +using WY.NewJit.Extends.PaiGe.WMS; + +namespace Win.Sfs.SettleAccount.Entities.WMS +{ + /// + /// wms出库-一汽轿车 + /// + + [AllowAnonymous] + [Route("api/settleaccount/WmsHQCaroutput")] + public class WmsHQCarAppService : + SettleAccountApplicationBase + { + private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; + private readonly ISettleAccountBranchEfCoreRepository _wmsVersionRepository; + private readonly WMSEfCoreRepository _wmsefRespository; + private readonly WmsDapperRepository _wmsDapper; + private readonly WMSEfCoreRepository _wmstbRespository; + private readonly ISettleAccountBranchEfCoreRepository _job; + private readonly IExcelImportAppService _excelImportService; + + private readonly TaskJobService _service; + /// + /// + /// + /// + /// + /// + /// + /// + public WmsHQCarAppService( + + ISettleAccountBranchEfCoreRepository wmsRepository, + ISettleAccountBranchEfCoreRepository job, + ISettleAccountBranchEfCoreRepository wmsVersionRepository, + WMSEfCoreRepository wmsefRespository, + WMSEfCoreRepository wmstbRespository, + IExcelImportAppService excelImportService, + IDistributedCache cache, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + WmsDapperRepository wmsDapper + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _excelImportService = excelImportService; + _job = job; + _wmstbRespository = wmstbRespository; + _wmsRepository = wmsRepository; + _wmsVersionRepository = wmsVersionRepository; + _wmsefRespository = wmsefRespository; + _wmsDapper = wmsDapper; + } + + private async Task GetCountAsync(WmsSharePartOutPutDetialRequestDto input) + { + return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); + } + + private async Task GetCountAsync(WmsSharePartOutPutRequestDto input) + { + return await _wmsVersionRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); + } + + /// + /// 准时化出库主表 + /// + /// + /// + [HttpPost] + [Route("WmsSharePartList")] + //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] + virtual public async Task> 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(totalCount, entities); + } + + /// + /// 准时化出库明细 + /// + /// + /// + [HttpPost] + [Route("WmsSharePartDetailList")] + //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] + virtual public async Task> GetListAsync(WmsSharePartOutPutDetialRequestDto 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.MaterialCode equals itm1.SapCode + into temp1 + from tm1 in temp1.DefaultIfEmpty() + select new WmsHQCarOutPutDetial( + itm.Id, + itm.WmsBillNum, + itm.OrderBillNum, + itm.MaterialCode, + itm.MaterialDesc, + itm.MaterialGroup, + itm.OutPut, + itm.InPut, + itm.State, + itm.Extend1, + itm.Extend2, + itm.Version, + itm.ParentMaterialCode, + itm.BillNum, + itm.TaskId, + itm.Remark, + itm.Qty, + tm1.Qty + ); + + + + + return new PagedResultDto(totalCount, query.ToList()); + } + /// + /// 任务明细标记已确认 + /// + /// 上传的文件(前端已经限制只能上传一个附件) + /// + [HttpPost] + [Route("WmsSharePartOutPutAudit")] + [DisableRequestSizeLimit] + + public async Task WmsSharePartAudit(List 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; + } + /// + /// 选择任务,生成出库单,只包含已确认的单据 + /// + /// + /// + /// + [HttpPost] + [Route("WmsSharePartOutPut")] + public async Task WmsSharePartOutPut(WmsJitRequestDto input) + { + var _billNum = "BHQ" + 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 _lst = new List(); + 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(); + if (_list.Count() > 0) + { + var _lsAry = _list.Select(p => new + WmsHQCarOutPutDetial( + GuidGenerator.Create(), + "", + string.Empty, + p.结算物料号, + p.物料描述, + p.物料组, + string.Empty, + string.Empty, + 0, + string.Empty, + string.Empty, + input.Version, + p.Sap编码, + _billNum, + GuidGenerator.Create(), + string.Empty, + p.结算数量, + 0 + )); + _lst.AddRange(_lsAry.ToArray()); + } + } + foreach (var itm in _lst) + { + itm.BillNum = _billNum; + } + await _wmsRepository.GetDbContext().BulkInsertAsync(_lst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); + if (_count == 0) + { + var _version = new WmsHQCarOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); + + await _wmsVersionRepository.InsertAsync(_version, true); + + } + + foreach (var job in _joblist) + { + job.FileName = _billNum; + await _job.UpdateAsync(job); + } + } + //return _billNum; + //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 ApplicationConsts.SuccessStr; + } + /// + /// 出库界面功能,核准出库功能 + /// + /// + /// + /// + [HttpPost] + [Route("WmsSharePartOutPut-Pass")] + [UnitOfWork(false)] + public async Task WmsSharePartOutPutPass(WmsJitRequestDto input) + { + if (input.Guids != null) + { + List _ls = new List(); + 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 sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output]\n" + + " @billnum = N'{0}',\n" + + " @type = 4\n" + + "SELECT 'Return Value' = @return_value"; + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + string.Format(sql, input.BillNum)); + + } + } + return true; + } + /// + ///出库界面功能, 撤销核准出库 + /// + /// + /// + /// + [HttpPost] + [Route("WmsSharePartOutPut-Cancel")] + public async Task WmsSharePartOutPutCancel(WmsJitRequestDto input) + { + if (input.Guids != null && input.Guids.Count() > 0) + { + List _ls = new List(); + 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 = 4,\n" + + " @accountdate = N'{2}'\n" + + "SELECT 'Return Value' = @return_value"; + + sql = string.Format(sql, str, input.BillNum, input.AccountDate); + + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + sql + ); + } + return true; + } + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] + public async Task ExcelImport([FromForm] IFormFileCollection files, string version) + { + var _billNum = "BHQ" + DateTime.Now.ToString("yyyyMMddhhmmss"); + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); + List _lst = new List(); + + var _lsCopy = new List(); + foreach (var itm in result) + { + WmsHQCarOutPutDetial _detail = new WmsHQCarOutPutDetial( + 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 + , 0 + ); + _lsCopy.Add(_detail); + } + _lst.AddRange(_lsCopy.ToArray()); + + + var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } + select itm1; + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + + var checkList = new List(); + foreach (var itm in errList) + { + checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); + } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + var query = from itm1 in _lst + join itm2 in outPutDetail on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } 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 WmsHQCarOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } + return _billNum; + } + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index 5170e3b1..aed229d1 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -528,7 +528,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices #region 红旗、一汽轿车的输出报表 /// - /// 一汽轿车 + /// 一汽轿车明细 /// /// /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index a2283ac8..26f471c2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -2661,6 +2661,66 @@ + + + wms出库-一汽轿车 + + + + + + + + + + + + + + + 准时化出库主表 + + + + + + + 准时化出库明细 + + + + + + + 任务明细标记已确认 + + 上传的文件(前端已经限制只能上传一个附件) + + + + + 选择任务,生成出库单,只包含已确认的单据 + + + + + + + + 出库界面功能,核准出库功能 + + + + + + + + 出库界面功能, 撤销核准出库 + + + + + wms出库-M平台 @@ -3392,7 +3452,7 @@ - 一汽轿车 + 一汽轿车明细 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index 74b4131f..45fca9ca 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -553,6 +553,122 @@ namespace Win.Sfs.SettleAccount.Entities.WMS #endregion + #region 一汽轿车出库 + /// + /// 一汽轿车出库 + /// + public class WmsHQCarOutPut : FullAuditedAggregateRootBase + { + public WmsHQCarOutPut() + { + } + public WmsHQCarOutPut(Guid id, string version, string billNum, string creator) : base(id) + { + Id = id; + Version = version; + BillNum = billNum; + Creator = creator; + } + public string Version { set; get; } + public string BillNum { set; get; } + public string Creator { set; get; } + + } + + + /// + /// 一汽轿车出库明细 + /// + public class WmsHQCarOutPutDetial : FullAuditedAggregateRootBase + { + + + + + public WmsHQCarOutPutDetial() + { + } + public WmsHQCarOutPutDetial(Guid id, string wmsBillNum, string orderBillNum, string materialCode, string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, string extend3, string parentMaterialCode, string billNum, Guid taskId, string remark, decimal qty, decimal stockQty) + { + Id = id; + WmsBillNum = wmsBillNum; + OrderBillNum = orderBillNum; + MaterialCode = materialCode; + MaterialDesc = materialDesc; + MaterialGroup = materialGroup; + OutPut = outPut; + InPut = inPut; + State = state; + Extend1 = extend1; + Extend2 = extend2; + Version = extend3; + ParentMaterialCode = parentMaterialCode; + BillNum = billNum; + TaskId = taskId; + Remark = remark; + Qty = qty; + StockQty = stockQty; + } + public void SetId(Guid id) + { + Id = id; + } + //交货单号 + + [ImporterHeader(Name = "寄销库数量", IsIgnore = true)] + public decimal StockQty { set; get; } + + [ImporterHeader(Name = "组件组物料", IsIgnore = true)] + public string ParentMaterialCode { set; get; } + [ImporterHeader(Name = "交货单号", IsIgnore = true)] + public string WmsBillNum { set; get; } + [ImporterHeader(Name = "看板号", IsIgnore = true)] + //KENN号 + public string OrderBillNum { set; get; } + [ImporterHeader(Name = "Sap编码")] + //物料号 + public string MaterialCode { set; get; } + [ImporterHeader(Name = "物料描述")] + //物料描述 + public string MaterialDesc { set; get; } + [ImporterHeader(Name = "物料组(车型)")] + //物料组(车型) + public string MaterialGroup { set; get; } + [ImporterHeader(Name = "出库库位", IsIgnore = true)] + //出库库位 + public string OutPut { set; get; } + [ImporterHeader(Name = "入库库位", IsIgnore = true)] + //入库库位 + public string InPut { set; get; } + [ImporterHeader(Name = "状态", IsIgnore = true)] + public int State { get; set; } + [ImporterHeader(Name = "结算物料号")] + /// + /// 扩展字段1 + /// + public string Extend1 { set; get; } + /// + /// 扩展字段2 + /// + [ImporterHeader(Name = "收货仓库")] + public string Extend2 { set; get; } + /// + /// 扩展字段3 + /// + [ImporterHeader(Name = "版本号", IsIgnore = true)] + public string Version { set; get; } + [ImporterHeader(Name = "结算数量")] + public decimal Qty { set; get; } + [ImporterHeader(Name = "单据号", IsIgnore = true)] + public string BillNum { set; get; } + [ImporterHeader(Name = "任务ID", IsIgnore = true)] + public Guid TaskId { set; get; } + } + #endregion + + + + #region 红旗看板 public class WmsHQFKanbanOutPut : FullAuditedAggregateRootBase