96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
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;
|
|
using EastChanger.STK_MisDelivery;
|
|
using EastChanger.STK_Miscellaneous;
|
|
|
|
namespace EastChanger
|
|
{
|
|
/// <summary>
|
|
/// 自定义校验器
|
|
/// </summary>
|
|
public class CustomsSyncVaildators : AbstractValidator
|
|
{
|
|
private readonly int _syncModuleId;
|
|
private readonly int _action;
|
|
/// <summary>
|
|
/// 自定义校验器 1.即时库存明细 2.物料入库单 3.成品出库单 4.盘盈单 5.盘亏单
|
|
/// </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://其他入库单
|
|
service = new STKMiscellaneousService(ctx);
|
|
break;
|
|
case 3://其他出库单
|
|
service = new STKMisDeliveryService(ctx);
|
|
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));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|