|
|
@ -1666,7 +1666,6 @@ namespace CK.SCP.Controller |
|
|
|
string _oldpartcode = ""; //上一个托盘所装零件编号
|
|
|
|
decimal _oldbox = 0; //上一个托盘箱数计数
|
|
|
|
string _oldpalletnum = "";//上一个托盘码
|
|
|
|
List<string> _listm = new List<string>(); |
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
var _askDetail = db.TA_VEND_PART.Where |
|
|
@ -1674,10 +1673,10 @@ namespace CK.SCP.Controller |
|
|
|
&& itm.PartCode == p.PartCode |
|
|
|
).FirstOrDefault(); |
|
|
|
if (_askDetail != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var _palletPack = _askDetail.PalletPackQty; |
|
|
|
#region 补充未满托盘
|
|
|
|
if (p.PartCode== _oldpartcode) |
|
|
|
if (p.PartCode == _oldpartcode) |
|
|
|
{ |
|
|
|
decimal _box1 = 0; |
|
|
|
int _TempQty1 = Convert.ToInt32(p.Qty); |
|
|
@ -1698,7 +1697,7 @@ namespace CK.SCP.Controller |
|
|
|
_box1++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(_box1< _oldbox) |
|
|
|
if (_box1 < _oldbox) |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
@ -1708,6 +1707,11 @@ namespace CK.SCP.Controller |
|
|
|
pallet.Box = Convert.ToInt32(_box1); |
|
|
|
pallet.Qty = p.Qty; |
|
|
|
pallet.PalletNum = _oldpalletnum; |
|
|
|
pallet.BarCode = _oldpalletnum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
p.Qty = 0; |
|
|
|
} |
|
|
@ -1719,10 +1723,15 @@ namespace CK.SCP.Controller |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.Box = Convert.ToInt32(_oldbox); |
|
|
|
pallet.Qty = _oldbox* _PackQty1; |
|
|
|
pallet.Qty = _oldbox * _PackQty1; |
|
|
|
pallet.PalletNum = _oldpalletnum; |
|
|
|
pallet.BarCode = _oldpalletnum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
p.Qty = p.Qty- _oldbox * _PackQty1; |
|
|
|
p.Qty = p.Qty - _oldbox * _PackQty1; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
@ -1758,6 +1767,12 @@ namespace CK.SCP.Controller |
|
|
|
pallet.Box = Convert.ToInt32(_box); |
|
|
|
pallet.Qty = p.Qty; |
|
|
|
pallet.PalletNum = SCP_BILLCODE_CONTROLLER.MakePalletCode_QD(codenum); |
|
|
|
pallet.BarCode = pallet.PalletNum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
|
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
_oldpartcode = p.PartCode; |
|
|
|
_oldbox = Convert.ToInt32(_palletPack) - _box; |
|
|
@ -1772,7 +1787,7 @@ namespace CK.SCP.Controller |
|
|
|
{ |
|
|
|
_pallet++; |
|
|
|
} |
|
|
|
for (int i = 1; i <= _pallet;i++) |
|
|
|
for (int i = 1; i <= _pallet; i++) |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
@ -1780,6 +1795,11 @@ namespace CK.SCP.Controller |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.PalletNum = SCP_BILLCODE_CONTROLLER.MakePalletCode_QD(codenum); |
|
|
|
pallet.BarCode = pallet.PalletNum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
if (i == _pallet) |
|
|
|
{ |
|
|
|
pallet.Box = Convert.ToInt32(_box - Convert.ToDecimal(_palletPack) * (_pallet - 1)); |
|
|
@ -1803,17 +1823,27 @@ namespace CK.SCP.Controller |
|
|
|
_list.Add(_str); |
|
|
|
} |
|
|
|
}); |
|
|
|
int state = db.SaveChanges(); |
|
|
|
if (state != -1) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.Result = true; |
|
|
|
if (_list.Count == 0) |
|
|
|
{ |
|
|
|
int state = db.SaveChanges(); |
|
|
|
if (state != -1) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.Result = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.MessageList = _list; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.MessageList = _listm; |
|
|
|
_ret.MessageList = _list; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1867,6 +1897,256 @@ namespace CK.SCP.Controller |
|
|
|
} |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
|
|
|
|
public static ResultObject<bool> Save_TB_PALLET_JZJH(List<V_TB_ASN_DETAIL> p_list) |
|
|
|
{ |
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
{ |
|
|
|
List<string> _list = new List<string>(); |
|
|
|
string _oldpartcode = ""; //上一个托盘所装零件编号
|
|
|
|
decimal _oldbox = 0; //上一个托盘箱数计数
|
|
|
|
string _oldpalletnum = "";//上一个托盘码
|
|
|
|
string _oldpalletfullnum = "";//上一个托盘码
|
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
var _askDetail = db.TA_VEND_PART.Where |
|
|
|
(itm => itm.VendId == p.VendId |
|
|
|
&& itm.PartCode == p.PartCode |
|
|
|
).FirstOrDefault(); |
|
|
|
if (_askDetail != null) |
|
|
|
{ |
|
|
|
var _palletPack = _askDetail.PalletPackQty; |
|
|
|
#region 补充未满托盘
|
|
|
|
if (p.PartCode== _oldpartcode) |
|
|
|
{ |
|
|
|
decimal _box1 = 0; |
|
|
|
int _TempQty1 = Convert.ToInt32(p.Qty); |
|
|
|
int _PackQty1 = Convert.ToInt32(p.PackQty); |
|
|
|
if (_TempQty1 / _PackQty1 > 0) |
|
|
|
{ |
|
|
|
int _count = _TempQty1 / _PackQty1; |
|
|
|
_box1 += _count; |
|
|
|
if (p.Qty % p.PackQty > 0) |
|
|
|
{ |
|
|
|
_box1++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (_TempQty1 > 0) |
|
|
|
{ |
|
|
|
_box1++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(_box1< _oldbox) |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
|
pallet.PartCode = p.PartCode; |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.Box = Convert.ToInt32(_box1); |
|
|
|
pallet.Qty = p.Qty; |
|
|
|
pallet.PalletNum = _oldpalletnum; |
|
|
|
pallet.BarCode = _oldpalletnum; |
|
|
|
pallet.FullBarCode = _oldpalletfullnum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate =Convert.ToDateTime( p.ProduceDate); |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
p.Qty = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
|
pallet.PartCode = p.PartCode; |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.Box = Convert.ToInt32(_oldbox); |
|
|
|
pallet.Qty = _oldbox* _PackQty1; |
|
|
|
pallet.PalletNum = _oldpalletnum; |
|
|
|
pallet.BarCode = _oldpalletnum; |
|
|
|
pallet.FullBarCode = _oldpalletfullnum; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
p.Qty = p.Qty- _oldbox * _PackQty1; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#region 新托盘
|
|
|
|
if (p.Qty != 0) |
|
|
|
{ |
|
|
|
decimal _box = 0; |
|
|
|
int _TempQty = Convert.ToInt32(p.Qty); |
|
|
|
int _PackQty = Convert.ToInt32(p.PackQty); |
|
|
|
if (_TempQty / _PackQty > 0) |
|
|
|
{ |
|
|
|
int _count = _TempQty / _PackQty; |
|
|
|
_box += _count; |
|
|
|
if (p.Qty % p.PackQty > 0) |
|
|
|
{ |
|
|
|
_box++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (_TempQty > 0) |
|
|
|
{ |
|
|
|
_box++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (_box <= _palletPack) |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
|
pallet.PartCode = p.PartCode; |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.Box = Convert.ToInt32(_box); |
|
|
|
pallet.Qty = p.Qty; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
var ret = SCP_BARCODE_CONTROLLER.CreatePallets(pallet); |
|
|
|
if (ret.State == ReturnStatus.Succeed) |
|
|
|
{ |
|
|
|
pallet.BarCode = pallet.PalletNum; |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
_oldpartcode = p.PartCode; |
|
|
|
_oldbox = Convert.ToInt32(_palletPack) - _box; |
|
|
|
_oldpalletnum = pallet.PalletNum; |
|
|
|
_oldpalletfullnum= pallet.FullBarCode; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
decimal _pallet = 0; |
|
|
|
_pallet += Convert.ToInt32(_box) / Convert.ToInt32(_palletPack); |
|
|
|
if (_box % _palletPack > 0) |
|
|
|
{ |
|
|
|
_pallet++; |
|
|
|
} |
|
|
|
for (int i = 1; i <= _pallet;i++) |
|
|
|
{ |
|
|
|
TB_PALLETS pallet = new TB_PALLETS(); |
|
|
|
pallet.AsnBillNum = p.AsnBillNum; |
|
|
|
pallet.PartCode = p.PartCode; |
|
|
|
pallet.Batch = p.Batch; |
|
|
|
pallet.VendId = p.VendId; |
|
|
|
pallet.VendBatch = p.VendBatch; |
|
|
|
pallet.PoBillLine = p.PoLine; |
|
|
|
pallet.PoBillNum = p.PoBillNum; |
|
|
|
pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); |
|
|
|
if (i == _pallet) |
|
|
|
{ |
|
|
|
pallet.Box = Convert.ToInt32(_box - Convert.ToDecimal(_palletPack) * (_pallet - 1)); |
|
|
|
pallet.Qty = p.Qty - Convert.ToDecimal(_palletPack) * (_pallet - 1) * _PackQty; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
pallet.Box = Convert.ToInt32(_palletPack); |
|
|
|
pallet.Qty = Convert.ToDecimal(_palletPack) * _PackQty; |
|
|
|
} |
|
|
|
var ret = SCP_BARCODE_CONTROLLER.CreatePallets(pallet); |
|
|
|
if (ret.State == ReturnStatus.Succeed) |
|
|
|
{ |
|
|
|
pallet.BarCode = pallet.PalletNum; |
|
|
|
db.TB_PALLETS.Add(pallet); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
string _str = string.Format("零件号:{0},供应商编号:{1},没有维护托盘标包数!请先维护供应商零件信息", p.PartCode, p.VendBatch); |
|
|
|
_list.Add(_str); |
|
|
|
} |
|
|
|
}); |
|
|
|
int state = db.SaveChanges(); |
|
|
|
if (_list.Count == 0) |
|
|
|
{ |
|
|
|
if (state != -1) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.Result = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.MessageList = _list; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.MessageList = _list; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{ |
|
|
|
var sb = new StringBuilder(); |
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList()) |
|
|
|
{ |
|
|
|
error.ValidationErrors.ToList().ForEach(i => |
|
|
|
{ |
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); |
|
|
|
}); |
|
|
|
} |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(dbEx); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", sb.ToString()); |
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); |
|
|
|
} |
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(ex); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", ex.ToString()); |
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); |
|
|
|
} |
|
|
|
catch (ScpException ex) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(ex); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", ex.ToString()); |
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) |
|
|
|
{ |
|
|
|
var inner = (UpdateException)ex.InnerException; |
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (ex.InnerException != null) throw ex.InnerException; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET", e.Message); |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
public static ResultObject<bool> Save_TB_CREATE_BARCODE_SYJB(List<V_TB_ASN_DETAIL> p_list) |
|
|
|
{ |
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|