25 changed files with 8676 additions and 273 deletions
File diff suppressed because one or more lines are too long
@ -0,0 +1,264 @@ |
|||
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,133 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace WY.NewJit.Extends.PaiGe.WMS |
|||
{ |
|||
public partial class TB_BILL:IEntity |
|||
{ |
|||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)] |
|||
[Display(AutoGenerateField = false)] |
|||
[ScaffoldColumn(false)] |
|||
public int UID { get; set; } |
|||
|
|||
[Key] |
|||
[StringLength(50)] |
|||
|
|||
[DisplayName("单据编号")] |
|||
[ExporterHeader(DisplayName = "单据编号")] |
|||
[ImporterHeader(Name = "单据编号")] |
|||
public string BillNum { get; set; } = ""; |
|||
|
|||
public int State { get; set; } |
|||
|
|||
[DisplayName("原始单据")] |
|||
[ExporterHeader(DisplayName = "原始单据")] |
|||
public string SourceBillNum { get; set; } = ""; |
|||
|
|||
//[StringLength(50)]
|
|||
[DisplayName("原始单据2")] |
|||
[ExporterHeader(DisplayName = "原始单据2")] |
|||
public string SourceBillNum2 { get; set; } = ""; |
|||
|
|||
//[StringLength(50)]
|
|||
[DisplayName("原始单据3")] |
|||
[ExporterHeader(DisplayName = "原始单据3")] |
|||
public string SourceBillNum3 { get; set; } = ""; |
|||
|
|||
[DisplayName("单据类型")] |
|||
[ExporterHeader(DisplayName = "单据类型")] |
|||
[NotMapped] |
|||
public string BillType { get; set; } |
|||
|
|||
[DisplayName("单据子类型")] |
|||
[ExporterHeader(DisplayName = "单据子类型")] |
|||
[NotMapped] |
|||
public string SubBillType { get; set; } |
|||
|
|||
[DisplayName("单据时间")] |
|||
[ExporterHeader(DisplayName = "单据时间")] |
|||
public DateTime BillTime { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("开始时间")] |
|||
[ExporterHeader(DisplayName = "开始时间")] |
|||
public string StartTime { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("结束时间")] |
|||
[ExporterHeader(DisplayName = "结束时间")] |
|||
public string FinishTime { get; set; } |
|||
|
|||
[Required(AllowEmptyStrings = true)] |
|||
[StringLength(50)] |
|||
[DisplayName("操作员")] |
|||
[ExporterHeader(DisplayName = "操作员")] |
|||
public string OperName { get; set; } |
|||
|
|||
[DisplayName("明细数量")] |
|||
[ExporterHeader(DisplayName = "明细数量")] |
|||
public int DetailQty { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("供应商编号")] |
|||
[ExporterHeader(DisplayName = "供应商编号")] |
|||
public string VendId { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("客户编号")] |
|||
[ExporterHeader(DisplayName = "客户编号")] |
|||
public string CustId { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("项目编号")] |
|||
[ExporterHeader(DisplayName = "项目编号")] |
|||
public string ProjectId { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("运输方式")] |
|||
[ExporterHeader(DisplayName = "运输方式")] |
|||
public string TransportType { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("车牌号")] |
|||
[ExporterHeader(DisplayName = "运输方式")] |
|||
public string TruckNum { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("到货门编号")] |
|||
[ExporterHeader(DisplayName = "到货门编号")] |
|||
public string GateCode { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("到货门名称")] |
|||
[ExporterHeader(DisplayName = "到货门名称")] |
|||
public string GateName { get; set; } |
|||
|
|||
//[StringLength(50)]
|
|||
[DisplayName("到货口编号")] |
|||
[ExporterHeader(DisplayName = "到货口编号")] |
|||
public string DockCode { get; set; } |
|||
|
|||
[DisplayName("备注")] |
|||
[ExporterHeader(DisplayName = "备注")] |
|||
public string Remark { get; set; } |
|||
|
|||
public DateTime? AccountDate { get; set; } |
|||
|
|||
|
|||
public Guid GUID { get; set; } = Guid.NewGuid(); |
|||
|
|||
public TB_BILL() |
|||
{ |
|||
} |
|||
|
|||
public object[] GetKeys() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,105 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
|
|||
namespace ChangKeTec.Wms.Models.Wms |
|||
{ |
|||
public partial class TS_SORT_DETAIL |
|||
{ |
|||
|
|||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)] |
|||
public long UID { get; set; } |
|||
|
|||
[Key] |
|||
[Column(Order = 0)] |
|||
[StringLength(50)] |
|||
[DisplayName("单据编号")] |
|||
public string BillNum { get; set; } |
|||
|
|||
[DisplayName("行号")] |
|||
public int LineNum { get; set; } |
|||
|
|||
[Key] |
|||
[Column(Order = 1)] |
|||
[StringLength(50)] |
|||
[DisplayName("VIN码")] |
|||
public string VinCode { get; set; } |
|||
|
|||
[Required(AllowEmptyStrings = true)] |
|||
[StringLength(50)] |
|||
[DisplayName("顺序号")] |
|||
public string SeqNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// SAP物料号
|
|||
/// </summary>
|
|||
[Key] |
|||
[Column(Order = 2)] |
|||
[StringLength(50)] |
|||
[DisplayName("物料号")] |
|||
public string PartCode { get; set; } |
|||
|
|||
[DisplayName("箱码")] |
|||
public string BarCode { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("客户物料号")] |
|||
public string CustPartCode { get; set; } |
|||
|
|||
|
|||
[Required(AllowEmptyStrings = true)] |
|||
[StringLength(50)] |
|||
[DisplayName("项目编号")] |
|||
public string ProjectId { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("FYON NUMBER")] |
|||
public string FyonNum { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("SUPPLIER")] |
|||
public string VendId { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("DOCK")] |
|||
public string Dock { get; set; } |
|||
|
|||
[StringLength(50)] |
|||
[DisplayName("DISPATCH DATE")] |
|||
public string DispatchDate { get; set; } |
|||
|
|||
[Required(AllowEmptyStrings = true)] |
|||
[StringLength(50)] |
|||
[DisplayName("状态")] |
|||
public string State { get; set; } |
|||
|
|||
[StringLength(200)] |
|||
[DisplayName("备注")] |
|||
public string Remark { get; set; } |
|||
|
|||
[Column(TypeName = "money")] |
|||
[DisplayName("计划数量")] |
|||
public decimal PlanQty { get; set; } = 0; |
|||
|
|||
[Column(TypeName = "money")] |
|||
[DisplayName("发货数量")] |
|||
public decimal Qty { get; set; } = 0; |
|||
|
|||
[StringLength(200)] |
|||
[DisplayName("客户条码")] |
|||
public string CustBarCode { get; set; } = string.Empty; |
|||
|
|||
[Column(TypeName = "money")] |
|||
[DisplayName("回执数量")] |
|||
public decimal ReceiptQty { get; set; } = 0; |
|||
|
|||
[StringLength(200)] |
|||
[DisplayName("箱码(Full)")] |
|||
public string FullBarCode { get; set; } = string.Empty; |
|||
|
|||
[NotMapped] |
|||
public string PartGroup { get; set; } |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue