a
This commit is contained in:
91
08.昶东/EastChanger/CustomsSyncVaildators.cs
Normal file
91
08.昶东/EastChanger/CustomsSyncVaildators.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Kingdee.BOS.Core.Validation;
|
||||
using Kingdee.BOS.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Kingdee.BOS;
|
||||
using ExtensionMethods;
|
||||
using EastChanger.STK_Inventory;
|
||||
using EastChanger.STK_StockCountGain;
|
||||
using EastChanger.STK_StockCountLoss;
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Util;
|
||||
|
||||
namespace EastChanger
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义校验器
|
||||
/// </summary>
|
||||
public class CustomsSyncVaildators : AbstractValidator
|
||||
{
|
||||
private readonly int _syncModuleId;
|
||||
private readonly int _action;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="syncModuleId">1.即时库存明细 2.物料入库单 3.成品出库单 4.盘盈单 5.盘亏单</param>
|
||||
/// <param name="action">1.删除</param>
|
||||
public CustomsSyncVaildators(int syncModuleId, int action = 1)
|
||||
{
|
||||
_syncModuleId = syncModuleId;
|
||||
_action = action;
|
||||
}
|
||||
|
||||
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx)
|
||||
{
|
||||
ISynchonService service = null;
|
||||
|
||||
switch (_syncModuleId)
|
||||
{
|
||||
case 1://即时库存明细
|
||||
break;
|
||||
case 2://其他入库单
|
||||
break;
|
||||
case 3://其他出库单
|
||||
break;
|
||||
case 4://盘盈单
|
||||
service = new STKStockCountGainService(ctx);
|
||||
break;
|
||||
case 5://盘亏单
|
||||
service = new STKStockCountLossService(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
IOperationResult opResult = new OperationResult();
|
||||
var ids = dataEntities.Select(x => x.DataEntity["Id"].ToString()).ToList();
|
||||
service.HandleSyncData(ids, opResult, this._action);
|
||||
if (opResult.OperateResult.Any())
|
||||
{
|
||||
foreach (var data in dataEntities)
|
||||
{
|
||||
var id = data.DataEntity["Id"].ToString();
|
||||
var syncStatus = data.DataEntity["FSTATUS"].Long2Int();
|
||||
if (syncStatus == 1 || syncStatus == -2)
|
||||
{
|
||||
var res = opResult.OperateResult.FirstOrDefault(x => x.Name.Equals(id) && x.SuccessStatus == false);
|
||||
if (res != null)
|
||||
{
|
||||
validateContext.AddError(
|
||||
data.DataEntity
|
||||
, new ValidationErrorInfo(
|
||||
""
|
||||
, id
|
||||
, data.DataEntityIndex
|
||||
, data.RowIndex
|
||||
, "001"
|
||||
, $"{res.Name} ,{res.Message}"
|
||||
, "同步海关信息" + data.BillNo
|
||||
, ErrorLevel.Error));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user