@ -32,6 +32,7 @@ using WY.NewJit.Extends.PaiGe.WMS;
using WY.NewJit.Filter ;
using WY.NewJit.Filter ;
using WY.NewJit.MsgBaseData ;
using WY.NewJit.MsgBaseData ;
using WY.NewJit.MsgCheck ;
using WY.NewJit.MsgCheck ;
using WY.NewJit.PrintTable ;
namespace Win.Sfs.SettleAccount.FISes
namespace Win.Sfs.SettleAccount.FISes
{
{
@ -54,6 +55,8 @@ namespace Win.Sfs.SettleAccount.FISes
private readonly LineSNDomianService _l ineSNDomianServic ;
private readonly LineSNDomianService _l ineSNDomianServic ;
private readonly IRepository < FisTB_BILL_SCRAP > _ tbBillScrapRepository ;
private readonly IRepository < FisTB_BILL_SCRAP > _ tbBillScrapRepository ;
private readonly IRepository < AlreadyPrint > _ alreadyPrintRepository ;
private readonly IRepository < WaitPrint > _ waitPrintRepository ;
/// <summary>
/// <summary>
/// 门板装箱单仓储明细
/// 门板装箱单仓储明细
@ -63,7 +66,9 @@ namespace Win.Sfs.SettleAccount.FISes
IRepository < BillM100 , Guid > billM100Repository ,
IRepository < BillM100 , Guid > billM100Repository ,
WMSDapperRepository wmsRepository ,
WMSDapperRepository wmsRepository ,
LineSNDomianService lineSNDomianServic ,
LineSNDomianService lineSNDomianServic ,
IRepository < FisTB_BILL_SCRAP > tbBillScrapRepository
IRepository < FisTB_BILL_SCRAP > tbBillScrapRepository ,
IRepository < AlreadyPrint > alreadyPrintRepository ,
IRepository < WaitPrint > waitPrintRepository
)
)
{
{
_ menBanPackingListRepository = menBanPackingListRepository ;
_ menBanPackingListRepository = menBanPackingListRepository ;
@ -71,6 +76,8 @@ namespace Win.Sfs.SettleAccount.FISes
_ wmsRepository = wmsRepository ;
_ wmsRepository = wmsRepository ;
_l ineSNDomianServic = lineSNDomianServic ;
_l ineSNDomianServic = lineSNDomianServic ;
_ tbBillScrapRepository = tbBillScrapRepository ;
_ tbBillScrapRepository = tbBillScrapRepository ;
_ alreadyPrintRepository = alreadyPrintRepository ;
_ waitPrintRepository = waitPrintRepository ;
}
}
private void DelOrScrapWMSInterface ( string billNum , bool isSynchronousMode = false )
private void DelOrScrapWMSInterface ( string billNum , bool isSynchronousMode = false )
@ -263,7 +270,7 @@ namespace Win.Sfs.SettleAccount.FISes
/// <returns>是否执行成功</returns>
/// <returns>是否执行成功</returns>
[HttpPost]
[HttpPost]
[Route("scrap")]
[Route("scrap")]
[UnitOfWork(isTransactional: false) ]
[UnitOfWork]
public virtual async Task < List < string > > ScrapAsync ( List < Guid > ids )
public virtual async Task < List < string > > ScrapAsync ( List < Guid > ids )
{
{
var selLst = await _ menBanPackingListRepository . Where ( p = > ids . Contains ( p . Id ) ) . ToListAsync ( ) ;
var selLst = await _ menBanPackingListRepository . Where ( p = > ids . Contains ( p . Id ) ) . ToListAsync ( ) ;
@ -335,17 +342,30 @@ namespace Win.Sfs.SettleAccount.FISes
//批量改为未打印
//批量改为未打印
var _ childList = await _ menBanPackingListRepository . Where ( p = > idList . Contains ( p . Id ) ) . SelectMany ( p = > p . Details ) . ToListAsync ( ) ;
var _ childList = await _ menBanPackingListRepository . Where ( p = > idList . Contains ( p . Id ) ) . SelectMany ( p = > p . Details ) . ToListAsync ( ) ;
var _ child = _ childList . Select ( p = > p . M100BillId ) . Distinct ( ) . ToList ( ) ;
var _ child = _ childList . Select ( p = > p . M100BillId ) . Distinct ( ) . ToList ( ) ;
var m100Lst = await _ billM100Repository . Where ( p = > _ child . Contains ( p . Id ) ) . ToListAsync ( ) ;
var _ apList = await _ alreadyPrintRepository . Where ( p = > _ child . Contains ( p . Id ) ) . ToListAsync ( ) ;
m100Lst . ForEach ( p = >
List < WaitPrint > _ wpList = new List < WaitPrint > ( ) ;
foreach ( var ap in _ apList )
{
{
if ( p . BillStatus = = BillStatusEnum . Publish )
var item = await _ waitPrintRepository . GetListAsync ( r = > r . HostSN2 = = ap . HostSN2 ) ;
if ( item . Count = = 0 )
{
{
p . SetBillStatus ( BillStatusEnum . Match ) ;
var wp = ObjectMapper . Map < AlreadyPrint , WaitPrint > ( ap ) ;
_ wpList . Add ( wp ) ;
}
}
p . PrintTime = null ;
else if ( item . Count = = 1 )
} ) ;
{
await _ billM100Repository . UpdateManyAsync ( m100Lst ) ;
if ( ap . BillStatus = = BillStatusEnum . BreakNum & & item [ 0 ] . BillStatus = = BillStatusEnum . BreakNum )
{
throw new BusinessException ( "1001" , "未打印列表和已打印列表出现都是断号的情况号码未【" + ap . HostSN2 + "】,不能报废!" ) ;
}
}
else if ( item . Count > 1 )
{
throw new BusinessException ( "1001" , "未打印列表里出现大众顺序号重复号码为【" + ap . HostSN2 + "】请检查后在报废!" ) ;
}
}
await _ alreadyPrintRepository . DeleteManyAsync ( _ apList ) ;
await _ waitPrintRepository . InsertManyAsync ( _ wpList ) ;
}
}
else
else
{
{
@ -354,6 +374,103 @@ namespace Win.Sfs.SettleAccount.FISes
return wmsLst . Select ( p = > p . BillNum ) . ToList ( ) ;
return wmsLst . Select ( p = > p . BillNum ) . ToList ( ) ;
}
}
///// <summary>
///// 报废
///// </summary>
///// <param name="ids">IDs</param>
///// <returns>是否执行成功</returns>
//[HttpPost]
//[Route("scrap")]
//[UnitOfWork(isTransactional: false)]
//public virtual async Task<List<string>> ScrapAsync(List<Guid> ids)
//{
// var selLst = await _menBanPackingListRepository.Where(p => ids.Contains(p.Id)).ToListAsync();
// if (selLst == null || selLst.Count == 0)
// {
// throw new BusinessException("1001", "没有选中要作废的已打印装箱单!");
// }
// foreach (var _obj in selLst)
// {
// string maxBillNum = await _menBanPackingListRepository.Where(itm => itm.ProductLine == _obj.ProductLine && itm.ReportStatus == ReportStatusEnum.已打印).MaxAsync(itm => itm.BillNum); //取当前生产线的最大装箱单号
// if (string.IsNullOrEmpty(maxBillNum) == false)
// {
// MenBanPackingList firObj = await _menBanPackingListRepository.FirstOrDefaultAsync(itm => itm.BillNum == maxBillNum);
// if (firObj != null)
// {
// if (_obj.SortId != firObj.SortId)
// {
// throw new BusinessException("1001", "只能报废当前生产线的最后打印单据,要报废的单据不是最后打印单据!");
// }
// }
// }
// }
// var sortList = selLst.Select(p => p.SortId).Distinct().ToList();//筛选出匹配门板
// List<MenBanPackingList> pairlist = _menBanPackingListRepository.Where(p => sortList.Contains(p.SortId)).ToList();
// var idList = pairlist.Select(p => p.Id).ToList();
// var _ls = pairlist.Select(p => p.BillNum).ToList();
// var _strList = new List<string>();
// _ls.ForEach(p => {
// _strList.Add(string.Format("'{0}'", p));
// });
// string str = string.Join(",", _strList.ToArray());
// var wmsLst = _wmsRepository.GetListBySql<TB_BILL>(string.Format("select top 100 * from TB_BILL with(nolock) where (state=1 or state=2) and BillNum in ({0}) ", str));
// if (wmsLst.Count() == 0) //库存没有排序
// {
// //调用库存系统接口
// List<string> billNumLst = pairlist.Select(itm => itm.BillNum).Distinct().ToList();
// foreach (string billNumStr in billNumLst)
// {
// DelOrScrapWMSInterface(billNumStr, true);
// }
// #region 作废时单据序号减一
// string curProductLine = selLst[0].ProductLine;
// DateTime curPrintDate = selLst[0].PrintDate;
// //string curPartType = selLst[0].PartType;
// var priorLst = _menBanPackingListRepository.Where(itm => itm.ReportStatus == ReportStatusEnum.已打印 && itm.ProductLine == curProductLine && idList.Contains(itm.Id) == false);
// if (priorLst.Any())
// {
// string maxBillNum = priorLst.Max(itm => itm.BillNum); //除去要作废记录,取当前生产线的最大单据号
// MenBanPackingList priorObj = priorLst.FirstOrDefault(itm => itm.BillNum == maxBillNum); //除去要作废记录,取当前生产线的最后打印记录
// double updRecCnt = await _lineSNDomianServic.SetMaxSN(ProductTypeEnum.门板, curProductLine, "", priorObj.PrintDate, priorObj.BillSerialNum.TryToDoubleZero(), null); //调用减号接口
// }
// else
// {
// double updRecCnt2 = await _lineSNDomianServic.SetMaxSN(ProductTypeEnum.门板, curProductLine, "", curPrintDate, 0, null); //调用减号接口,没有上条记录时 单据号传0
// }
// #endregion
// foreach (var itm in pairlist)
// {
// itm.ReportStatus = WY.NewJit.Extends.PaiGe.ReportStatusEnum.已作废;
// }
// await _menBanPackingListRepository.UpdateManyAsync(pairlist);
// //批量改为未打印
// var _childList = await _menBanPackingListRepository.Where(p => idList.Contains(p.Id)).SelectMany(p => p.Details).ToListAsync();
// var _child = _childList.Select(p => p.M100BillId).Distinct().ToList();
// var m100Lst = await _billM100Repository.Where(p => _child.Contains(p.Id)).ToListAsync();
// m100Lst.ForEach(p =>
// {
// if (p.BillStatus == BillStatusEnum.Publish)
// {
// p.SetBillStatus(BillStatusEnum.Match);
// }
// p.PrintTime = null;
// });
// await _billM100Repository.UpdateManyAsync(m100Lst);
// }
// else
// {
// throw new BusinessException("1001", "WMS已经排序,不能报废!");
// }
// return wmsLst.Select(p => p.BillNum).ToList();
//}
}
}
}
}