@ -927,7 +927,6 @@ namespace CK.SCP.GrupUniApi.Controller
var maxlist1 = new xxDiMaxes_Po
var maxlist1 = new xxDiMaxes_Po
{
{
Di_Batchno = qadPoNbr . DI_BATCHNO ,
Di_Batchno = qadPoNbr . DI_BATCHNO ,
} ;
} ;
xxMaxbath . Add ( maxlist1 ) ;
xxMaxbath . Add ( maxlist1 ) ;
@ -1638,50 +1637,64 @@ namespace CK.SCP.GrupUniApi.Controller
{
{
try
try
{
{
var max = idb . xxDiMaxes_Po . OrderByDescending ( r = > r . Di_Batchno ) . FirstOrDefault ( ) ;
// 读取一年内 所有审批完的一般材料订单
int a = max . Di_Batchno ;
DataTable b = GetGeneralMaterialOrder ( ) ;
var FATCTORY = sdb . TB_FACTORY . FirstOrDefault ( ) ;
List < GeneralMaterialOrder > orderlist = ChangKeTec . Utils . ListHelper . DataTableToList < GeneralMaterialOrder > ( b ) ;
// 黍龰珨啜第蹋隆等
List < xxDiMaxes_Order > maxes_Orders = ChangKeTec . Utils . ListHelper . DataTableToList < xxDiMaxes_Order > ( b ) ;
DataTable b = GetGeneralMaterialOrder ( a , FATCTORY . FactoryId ) ;
DateTime time = DateTime . Now . AddYears ( - 1 ) ;
List < GeneralMaterialOrder > list = ChangKeTec . Utils . ListHelper . DataTableToList < GeneralMaterialOrder > ( b ) ;
var hisList = idb . xxDiMaxes_Order . Where ( q = > q . CREATEDDATE > time ) . ToList ( ) ;
// 取历史表不存在的数据
var expectedList = maxes_Orders . Where ( x = > ! hisList . Any ( e = > e . DI_BATCHNO = = x . DI_BATCHNO & & e . PURDOCNO = = x . PURDOCNO & & e . PURDOCITEMNO = = x . PURDOCITEMNO ) ) . ToList ( ) ;
if ( expectedList . Count ( ) = = 0 )
{
return ;
}
List < GeneralMaterialOrder > list = new List < GeneralMaterialOrder > ( ) ;
foreach ( var exitem in expectedList )
{
var selectList = orderlist . Where ( q = > q . PURDOCNO = = exitem . PURDOCNO & & q . DI_BATCHNO = = exitem . DI_BATCHNO & & q . PURDOCITEMNO = = exitem . PURDOCITEMNO ) . ToList ( ) ;
list . AddRange ( selectList ) ;
}
var PoList = new List < TB_MATERIALORDERS > ( ) ;
var PoList = new List < TB_MATERIALORDERS > ( ) ;
var PoDetailList = new List < TB_MATERIALORDERS_DETAIL > ( ) ;
var PoDetailList = new List < TB_MATERIALORDERS_DETAIL > ( ) ;
var InPoList = new List < TB_MATERIALORDERS > ( ) ;
var InPoList = new List < TB_MATERIALORDERS > ( ) ;
var InPoDetailList = new List < TB_MATERIALORDERS_DETAIL > ( ) ;
var InPoDetailList = new List < TB_MATERIALORDERS_DETAIL > ( ) ;
var xxMaxbath = new List < xxDiMaxes_Po > ( ) ;
var xxMaxbath = new List < xxDiMaxes_Order > ( ) ;
var emails = new List < TS_Email > ( ) ;
var emails = new List < TS_Email > ( ) ;
var Dlist = list . Where ( p = > p . CTYPE = = "D" ) ;
var Dlist = list . Where ( p = > p . CTYPE = = "D" ) ;
var Ilist = list . Where ( p = > p . CTYPE ! = "D" ) . GroupBy ( p = > p . PURDOCNO ) . Distinct ( ) ;
var Ilist = list . Where ( p = > p . CTYPE = = "I ") . GroupBy ( p = > p . PURDOCNO ) . Distinct ( ) ;
var _D list = Dlist . GroupBy ( p = > p . PURDOCNO ) . Distinct ( ) ;
var _D list = Dlist . GroupBy ( p = > p . PURDOCNO ) . Distinct ( ) ;
string wwadres = sdb . TA_CONFIG . FirstOrDefault ( q = > q . ParamName = = "接口邮件网址" ) . ParamValue ;
string wwadres = sdb . TA_CONFIG . FirstOrDefault ( q = > q . ParamName = = "接口邮件网址" ) . ParamValue ;
foreach ( var DeleteItem in _D list )
foreach ( var DeleteItem in _D list )
{
{
var _l ist = DeleteItem . ToList ( ) ;
var _l ist = DeleteItem . ToList ( ) ;
var _ entity = _l ist . First ( ) ;
var _ entity = _l ist . First ( ) ;
// 跦擂 隆等瘍釬煙
//var MATERIALORDERList = sdb.TB_MATERIALORDERS.Where(q => q.PurdocNO == _entity.PURDOCNO).ToList();
//MATERIALORDERList.ForEach(p =>
//{
// p.Ctype = "D" ;
// p.AcceptStatus = (int)GeneralMaterialOrderState.Cancel;
// PoList.Add(p);
//});
foreach ( var Ditem in _l ist )
foreach ( var Ditem in _l ist )
{
{
var MATERIALORDERDETAILList = sdb . TB_MATERIALORDERS_DETAIL . Where ( q = > q . PurdocNO = = Ditem . PURDOCNO & & q . PURDOCITEMNO = = Ditem . PURDOCITEMNO ) . ToList ( ) ;
var MATERIALORDERDETAILList = sdb . TB_MATERIALORDERS_DETAIL . Where ( q = > q . PurdocNO = = Ditem . PURDOCNO ) . ToList ( ) ;
if ( MATERIALORDERDETAILList . Count ( ) = = 0 )
{
continue ;
}
MATERIALORDERDETAILList . ForEach ( p = >
MATERIALORDERDETAILList . ForEach ( p = >
{
{
p . Ctype = "D" ;
if ( p . PURDOCITEMNO = = Ditem . PURDOCITEMNO )
{
p . Ctype = Ditem . CTYPE ;
p . AcceptStatus = ( int ) GeneralMaterialOrderState . Cancel ;
p . AcceptStatus = ( int ) GeneralMaterialOrderState . Cancel ;
PoDetailList . Add ( p ) ;
PoDetailList . Add ( p ) ;
}
} ) ;
} ) ;
var valueType = MATERIALORDERDETAILList . Select ( q = > q . Ctype ) . Distinct ( ) . ToList ( ) ;
var valueType = MATERIALORDERDETAILList . Select ( q = > q . Ctype ) . Distinct ( ) . ToList ( ) ;
var type = valueType . FirstOrDefault ( ) ;
var type = valueType . FirstOrDefault ( ) ;
// 子表全是d并且唯一 更新主表
if ( valueType . Count ( ) = = 1 & & type = = "D" )
if ( valueType . Count ( ) = = 1 & & type = = "D" )
{
{
var MATERIALORDERList = sdb . TB_MATERIALORDERS . Where ( q = > q . PurdocNO = = Ditem . PURDOCNO ) . ToList ( ) ;
var MATERIALORDERList = sdb . TB_MATERIALORDERS . Where ( q = > q . PurdocNO = = Ditem . PURDOCNO ) . ToList ( ) ;
MATERIALORDERList . ForEach ( p = >
MATERIALORDERList . ForEach ( p = >
{
{
p . AcceptStatus = ( int ) GeneralMaterialOrderState . Cancel ;
p . Ctype = "D" ;
p . Ctype = "D" ;
PoList . Add ( p ) ;
PoList . Add ( p ) ;
} ) ;
} ) ;
@ -1712,14 +1725,27 @@ namespace CK.SCP.GrupUniApi.Controller
emails . Add ( email ) ;
emails . Add ( email ) ;
#endregion
#endregion
}
}
else //否则将主表变成新建状态
{
var MATERIALORDERList = sdb . TB_MATERIALORDERS . Where ( q = > q . PurdocNO = = Ditem . PURDOCNO ) . ToList ( ) ;
MATERIALORDERList . ForEach ( p = >
{
p . Ctype = "N" ;
p . AcceptStatus = ( int ) GeneralMaterialOrderState . New ;
PoList . Add ( p ) ;
} ) ;
}
}
var maxlist1 = new xxDiMaxes_Order
var maxlist1 = new xxDiMaxes_Po
{
{
Di_Batchno = _ entity . DI_BATCHNO ,
DI_BATCHNO = Ditem . DI_BATCHNO ,
PURDOCNO = Ditem . PURDOCNO ,
PURDOCITEMNO = Ditem . PURDOCITEMNO ,
CREATEDDATE = Ditem . CREATEDDATE ,
} ;
} ;
xxMaxbath . Add ( maxlist1 ) ;
xxMaxbath . Add ( maxlist1 ) ;
}
}
}
foreach ( var InsertItem in Ilist )
foreach ( var InsertItem in Ilist )
@ -1766,6 +1792,14 @@ namespace CK.SCP.GrupUniApi.Controller
orderdetail . StoreLocation = initem . STORELOCATION ;
orderdetail . StoreLocation = initem . STORELOCATION ;
orderdetail . PURDOCITEMNO = initem . PURDOCITEMNO ;
orderdetail . PURDOCITEMNO = initem . PURDOCITEMNO ;
InPoDetailList . Add ( orderdetail ) ;
InPoDetailList . Add ( orderdetail ) ;
var maxlist1 = new xxDiMaxes_Order
{
DI_BATCHNO = initem . DI_BATCHNO ,
PURDOCNO = initem . PURDOCNO ,
PURDOCITEMNO = initem . PURDOCITEMNO ,
CREATEDDATE = initem . CREATEDDATE ,
} ;
xxMaxbath . Add ( maxlist1 ) ;
}
}
#endregion
#endregion
#region
#region
@ -1793,19 +1827,14 @@ namespace CK.SCP.GrupUniApi.Controller
}
}
emails . Add ( email ) ;
emails . Add ( email ) ;
#endregion
#endregion
var maxlist1 = new xxDiMaxes_Po
{
Di_Batchno = inentity . DI_BATCHNO ,
} ;
xxMaxbath . Add ( maxlist1 ) ;
}
}
sdb . BulkInsert ( emails ) ; // 添加一般材料订单的邮件
sdb . BulkInsert ( emails ) ; // 添加一般材料订单的邮件
sdb . BulkInsert ( InPoList ) ; // 添加插入的数据
sdb . BulkInsert ( InPoList ) ; // 添加插入的数据
sdb . BulkInsert ( InPoDetailList ) ; // 添加明细
sdb . BulkInsert ( InPoDetailList ) ; // 添加明细
item . Remark = ( ( int ) UniApiState . 成 功 ) . ToString ( ) ;
item . Remark = ( ( int ) UniApiState . 成 功 ) . ToString ( ) ;
item . MaxdibatchNO = item . MaxdibatchNO + list . Count ;
item . MaxdibatchNO = item . MaxdibatchNO + list . Count ;
idb . xxDiMaxes_Po . AddOrUpdate ( xxMaxbath . ToArray ( ) ) ;
idb . xxDiMaxes_Order . AddOrUpdate ( xxMaxbath . ToArray ( ) ) ;
// 更新
// 更新
sdb . TB_MATERIALORDERS . BulkUpdate ( PoList ) ;
sdb . TB_MATERIALORDERS . BulkUpdate ( PoList ) ;
sdb . TB_MATERIALORDERS_DETAIL . BulkUpdate ( PoDetailList ) ;
sdb . TB_MATERIALORDERS_DETAIL . BulkUpdate ( PoDetailList ) ;