|
|
@ -71,47 +71,95 @@ namespace Win.Sfs.SettleAccount.Entities.WMS |
|
|
|
var _count= _wmsRepository.Count(p => p.Version == version && p.State>0); |
|
|
|
if (_count > 0) |
|
|
|
{ |
|
|
|
throw new BusinessException("8899", "不能重新生成此版本!"); |
|
|
|
var _query= _wmsRepository.Where(p => p.State == 0 && p.Version == version); |
|
|
|
await _query.BatchDeleteAsync(); |
|
|
|
var _query1= _wmsRepository.Where(p => p.Version == version); |
|
|
|
var _existLst = _query1.ToList(); |
|
|
|
var _maxLine = _existLst.Max(p => p.LineNumber); |
|
|
|
var _diffls = from itm1 in _ls |
|
|
|
join itm2 in _existLst |
|
|
|
on new { BillNum=itm1.结算单, MaterialCode=itm1.物料号, Pric=itm1.开票单价 } |
|
|
|
equals new { BillNum = itm2.BillNum, MaterialCode = itm2.MaterialCode, Pric = itm2.Price } into temp1 |
|
|
|
from tm1 in temp1.DefaultIfEmpty() |
|
|
|
select itm1; |
|
|
|
var _difflst=_diffls.ToList(); |
|
|
|
List<WmsDetailReport> _lst = new List<WmsDetailReport>(); |
|
|
|
if (_difflst != null && _difflst.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var itm in _difflst) |
|
|
|
{ |
|
|
|
_maxLine = _maxLine++; |
|
|
|
_lst.Add(new WmsDetailReport(Guid.NewGuid(), |
|
|
|
_maxLine, |
|
|
|
itm.客户, |
|
|
|
itm.出库类型, |
|
|
|
itm.结算编码, |
|
|
|
itm.销售渠道, |
|
|
|
itm.客户代码, |
|
|
|
itm.结算单, |
|
|
|
itm.物料号, |
|
|
|
String.Empty, |
|
|
|
itm.结算数量, |
|
|
|
itm.实际出库数量, |
|
|
|
itm.差异数量, |
|
|
|
itm.开票单价, |
|
|
|
itm.结算金额, |
|
|
|
itm.已出库金额, |
|
|
|
itm.WMS待出库金额, |
|
|
|
itm.物料组编码, |
|
|
|
itm.物料组车型, |
|
|
|
itm.物料描述, |
|
|
|
String.Empty, |
|
|
|
0, |
|
|
|
version, |
|
|
|
DateTime.MaxValue |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var query = _wmsRepository.Where(p => p.Version == version); |
|
|
|
_wmsRepository.GetDbContext().BulkDelete(query.ToList()); |
|
|
|
await query.BatchDeleteAsync(); |
|
|
|
} |
|
|
|
List<WmsDetailReport> _lst = new List<WmsDetailReport>(); |
|
|
|
if (_ls != null && _ls.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var itm in _ls) |
|
|
|
List<WmsDetailReport> _lst = new List<WmsDetailReport>(); |
|
|
|
if (_ls != null && _ls.Count() > 0) |
|
|
|
{ |
|
|
|
_lst.Add(new WmsDetailReport(Guid.NewGuid(), |
|
|
|
int.Parse(itm.行号), |
|
|
|
itm.客户, |
|
|
|
itm.出库类型, |
|
|
|
itm.结算编码, |
|
|
|
itm.销售渠道, |
|
|
|
itm.客户代码, |
|
|
|
itm.结算单, |
|
|
|
itm.物料号, |
|
|
|
String.Empty, |
|
|
|
itm.结算数量, |
|
|
|
itm.实际出库数量, |
|
|
|
itm.差异数量, |
|
|
|
itm.开票单价, |
|
|
|
itm.结算金额, |
|
|
|
itm.已出库金额, |
|
|
|
itm.WMS待出库金额, |
|
|
|
itm.物料组编码, |
|
|
|
itm.物料组车型, |
|
|
|
itm.物料描述, |
|
|
|
String.Empty, |
|
|
|
0, |
|
|
|
version, |
|
|
|
DateTime.MaxValue |
|
|
|
)); |
|
|
|
foreach (var itm in _ls) |
|
|
|
{ |
|
|
|
_lst.Add(new WmsDetailReport(Guid.NewGuid(), |
|
|
|
int.Parse(itm.行号), |
|
|
|
itm.客户, |
|
|
|
itm.出库类型, |
|
|
|
itm.结算编码, |
|
|
|
itm.销售渠道, |
|
|
|
itm.客户代码, |
|
|
|
itm.结算单, |
|
|
|
itm.物料号, |
|
|
|
String.Empty, |
|
|
|
itm.结算数量, |
|
|
|
itm.实际出库数量, |
|
|
|
itm.差异数量, |
|
|
|
itm.开票单价, |
|
|
|
itm.结算金额, |
|
|
|
itm.已出库金额, |
|
|
|
itm.WMS待出库金额, |
|
|
|
itm.物料组编码, |
|
|
|
itm.物料组车型, |
|
|
|
itm.物料描述, |
|
|
|
String.Empty, |
|
|
|
0, |
|
|
|
version, |
|
|
|
DateTime.MaxValue |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); |
|
|
|
await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); |
|
|
|
} |
|
|
|
|
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
@ -197,19 +245,31 @@ namespace Win.Sfs.SettleAccount.Entities.WMS |
|
|
|
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, |
|
|
|
0, true); |
|
|
|
|
|
|
|
entities = entities.Where(p => p.OutputQty != 0 && p.State==0).ToList(); |
|
|
|
var _count= entities.Count(p => p.State==2); |
|
|
|
|
|
|
|
|
|
|
|
await _wmsRepository.GetDbContext().BulkUpdateAsync(entities); |
|
|
|
if (_count > 1) |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "记录不在同一物料组车型、出库类型、客户编码"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var count = entities.GroupBy(p => new { p.Type, p.ClientCode }).Count(); |
|
|
|
|
|
|
|
if (count > 1) |
|
|
|
foreach (var itm in entities) |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "记录不在同一物料组车型、出库类型、客户编码"); |
|
|
|
return false; |
|
|
|
itm.State = 2; |
|
|
|
} |
|
|
|
await _wmsRepository.GetDbContext().BulkUpdateAsync(entities); |
|
|
|
|
|
|
|
|
|
|
|
// var count = entities.GroupBy(p => new { p.Type, p.ClientCode }).Count();
|
|
|
|
|
|
|
|
//if (count > 1)
|
|
|
|
// {
|
|
|
|
// throw new BusinessException("8989", "记录不在同一物料组车型、出库类型、客户编码");
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
List<WmsDetailReport> _ls = new List<WmsDetailReport>(); |
|
|
|
if (entities.Count() > 0) |
|
|
|