1
This commit is contained in:
@@ -19,6 +19,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
base.OnPreparePropertys(e);
|
||||
//添加需要加载的字段:
|
||||
e.FieldKeys.Add("FLimitCustomer");
|
||||
//产品类型
|
||||
e.FieldKeys.Add("F_MaterialModelGroup");
|
||||
e.FieldKeys.Add("FMaterialId");
|
||||
e.FieldKeys.Add("FSeq");
|
||||
@@ -29,6 +30,8 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
e.FieldKeys.Add("F_AgreePrice");
|
||||
|
||||
e.FieldKeys.Add("FCustID");
|
||||
e.FieldKeys.Add("FEntryEffectiveDate");//生效日期
|
||||
e.FieldKeys.Add("FEntryExpiryDate");//失效日期
|
||||
}
|
||||
|
||||
public override void OnAddValidators(AddValidatorsEventArgs e)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Kingdee.BOS;
|
||||
using Gatedge.K3.Pilot.PlugIn.Models.Validate;
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Core;
|
||||
using Kingdee.BOS.Core.Validation;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
@@ -9,6 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
{
|
||||
@@ -20,16 +22,28 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
{
|
||||
var limitCustomer = data.DataEntity["LimitCustomer"].Long2Int();
|
||||
var entrys = data.DataEntity["BD_CustPriceEntry"] as DynamicObjectCollection;
|
||||
//var idx = 0;
|
||||
var periodValidityList = new List<PeriodValidity>();
|
||||
foreach (var entry in entrys)
|
||||
{
|
||||
var idx = entry["Seq"].Long2Int() - 1;
|
||||
var pvData = new PeriodValidity
|
||||
{
|
||||
Seq = entry["Seq"].Long2Int(),
|
||||
MaterialModelGroup = entry["MaterialModelGroup"]?.ToString(),
|
||||
MaterialId = entry["MaterialId_Id"].Long2Int(),
|
||||
EffectiveDate = entry["EffectiveDate"] is DateTime ed ? ed : DateTime.MinValue,
|
||||
ExpirationDate = entry["ExpiryDate"] is DateTime exd ? exd : DateTime.MinValue
|
||||
};
|
||||
|
||||
var seq = entry["Seq"].Long2Int();
|
||||
//大客户
|
||||
if (limitCustomer == 1)
|
||||
{
|
||||
if (entry["MaterialModelGroup"].IsNullOrEmptyOrWhiteSpace())
|
||||
var materialModelGroup = entry["MaterialModelGroup"]?.ToString();
|
||||
if (materialModelGroup.IsNullOrEmptyOrWhiteSpace())
|
||||
{
|
||||
var title = "物料规格类型必填!";
|
||||
var msg = $"限定客户类型为大客户时,{title}";
|
||||
var msg = $"客户类型为大客户时,{title}";
|
||||
var displayToFieldKey = "F_MaterialModelGroup";
|
||||
|
||||
validateContext.AddError(data
|
||||
@@ -37,7 +51,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
displayToFieldKey// 出错的字段Key,可以空
|
||||
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
|
||||
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
|
||||
, idx// 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, seq// 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
|
||||
, msg // 错误的详细提示信息
|
||||
, title// 错误的简明提示信息
|
||||
@@ -49,7 +63,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
if (entry["BigCustSettlePrice"].Convert<decimal>() == 0M)
|
||||
{
|
||||
var title = "大客户底价必填!";
|
||||
var msg = $"限定客户类型为大客户时,{title}";
|
||||
var msg = $"客户类型为大客户时,{title}";
|
||||
var displayToFieldKey = "F_BigCustSettlePrice";
|
||||
|
||||
validateContext.AddError(data
|
||||
@@ -57,7 +71,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
displayToFieldKey// 出错的字段Key,可以空
|
||||
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
|
||||
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
|
||||
, idx// 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, seq// 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
|
||||
, msg // 错误的详细提示信息
|
||||
, title// 错误的简明提示信息
|
||||
@@ -65,8 +79,15 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//设置分组Id
|
||||
var first = periodValidityList.FirstOrDefault(w => w.MaterialModelGroup.Contains(pvData.MaterialModelGroup) || pvData.MaterialModelGroup.Contains(w.MaterialModelGroup));
|
||||
|
||||
pvData.GroupId = first == null ? pvData.Seq : first.GroupId;
|
||||
}
|
||||
|
||||
periodValidityList.Add(pvData);
|
||||
|
||||
//协议客户
|
||||
if (limitCustomer == 2)
|
||||
{
|
||||
@@ -81,7 +102,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
displayToFieldKey// 出错的字段Key,可以空
|
||||
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
|
||||
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
|
||||
, idx // 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, seq // 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
|
||||
, msg // 错误的详细提示信息
|
||||
, title// 错误的简明提示信息
|
||||
@@ -101,7 +122,7 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
displayToFieldKey// 出错的字段Key,可以空
|
||||
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
|
||||
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
|
||||
, idx // 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, seq // 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
|
||||
, msg // 错误的详细提示信息
|
||||
, title// 错误的简明提示信息
|
||||
@@ -109,12 +130,14 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
)
|
||||
);
|
||||
}
|
||||
//设置分组Id
|
||||
pvData.GroupId = pvData.MaterialId;
|
||||
}
|
||||
|
||||
if (limitCustomer == 0)
|
||||
{
|
||||
var title = "限定客户必填!";
|
||||
var msg = $"限定客户不能为空";
|
||||
var title = "客户类型必填!";
|
||||
var msg = $"客户类型不能为空";
|
||||
var displayToFieldKey = "FMaterialId";
|
||||
|
||||
validateContext.AddError(data
|
||||
@@ -133,6 +156,56 @@ namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
|
||||
|
||||
}
|
||||
|
||||
if (limitCustomer != 0 && periodValidityList.Count > 1)
|
||||
{
|
||||
//筛选出需要校验的数据
|
||||
//大客户:产品类型不为空的
|
||||
//协议客户:物料Id不为0的
|
||||
var selList = periodValidityList.Where(w =>
|
||||
(limitCustomer == 1 && !w.MaterialModelGroup.IsNullOrEmptyOrWhiteSpace())
|
||||
|| (limitCustomer == 2 && !(w.MaterialId == 0))
|
||||
).ToList();
|
||||
|
||||
if (selList.Any())
|
||||
{
|
||||
var groupList = selList.GroupBy(g => g.GroupId).Where(wg => wg.Count() > 1).ToList();
|
||||
|
||||
foreach (var group in groupList)
|
||||
{
|
||||
var items = group.ToList().OrderBy(o => o.EffectiveDate).ToList();
|
||||
for (int i = 0; i < items.Count - 1; i++)
|
||||
{
|
||||
var currentItem = items[i];
|
||||
var currSeq = currentItem.Seq;
|
||||
for (int j = i + 1; j < items.Count; j++)
|
||||
{
|
||||
var compareItem = items[j];
|
||||
if (currentItem.ExpirationDate >= compareItem.EffectiveDate)
|
||||
{
|
||||
var seq = compareItem.Seq;
|
||||
var title = "同物料、产品类型,效期不能重叠!";
|
||||
var msg = $"第【{seq}】行与第【{currSeq}】行效期重叠!";
|
||||
var displayToFieldKey = "FEntryEffectiveDate";
|
||||
|
||||
validateContext.AddError(data
|
||||
, new ValidationErrorInfo(
|
||||
displayToFieldKey// 出错的字段Key,可以空
|
||||
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
|
||||
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
|
||||
, seq// 出错的数据行在全部数据行中的顺序,如果校验基于单据头,此为0
|
||||
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
|
||||
, msg // 错误的详细提示信息
|
||||
, title// 错误的简明提示信息
|
||||
, ErrorLevel.Error // 错误级别:警告、错误...
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var entrys2 = data.DataEntity["BD_CustPriceCustEntry"] as DynamicObjectCollection;
|
||||
|
||||
if (limitCustomer != 1 && (entrys2 == null || entrys2.Count == 0))
|
||||
|
||||
Reference in New Issue
Block a user