a
This commit is contained in:
41
08.昶东/EastChanger/STK_StockCountLoss/ListEventPlugInEx.cs
Normal file
41
08.昶东/EastChanger/STK_StockCountLoss/ListEventPlugInEx.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.List.PlugIn;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace EastChanger.STK_StockCountLoss
|
||||
{
|
||||
[Description("【列表插件】【1.海关同步】"), HotUpdate]
|
||||
public class ListEventPlugInEx : AbstractListPlugIn
|
||||
{
|
||||
private IOperationResult opResult;
|
||||
|
||||
public override void BarItemClick(BarItemClickEventArgs e)
|
||||
{
|
||||
base.BarItemClick(e);
|
||||
//同步海关信息
|
||||
if (e.BarItemKey.Equals("InventoryProfit"))
|
||||
{
|
||||
var list = this.ListView.SelectedRowsInfo;
|
||||
if (!list.Any())
|
||||
{
|
||||
this.View.ShowErrMessage("请选择需要同步的单据");
|
||||
return;
|
||||
}
|
||||
|
||||
opResult = new OperationResult();
|
||||
var fidList = list.Select(x => x.PrimaryKeyValue).Distinct().ToList();
|
||||
ISynchonService service = new STKStockCountLossService(this.Context);
|
||||
service.HandleSyncData(fidList, opResult, 0);
|
||||
|
||||
if (opResult.OperateResult.Any())
|
||||
this.View.ShowOperateResult(opResult.OperateResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using ExtensionMethods;
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.Core;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.Validation;
|
||||
using Kingdee.BOS.TCP;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace EastChanger.STK_StockCountLoss
|
||||
{
|
||||
public class OperationEventPlugInEx : AbstractOperationServicePlugIn
|
||||
{
|
||||
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
||||
{
|
||||
base.OnPreparePropertys(e);
|
||||
e.FieldKeys.Add("FSTATUS");
|
||||
}
|
||||
/// <summary>
|
||||
/// 单据校验
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void OnAddValidators(AddValidatorsEventArgs e)
|
||||
{
|
||||
if (this.FormOperation.OperationId == 3)
|
||||
{
|
||||
base.OnAddValidators(e);
|
||||
var validator = new CustomsSyncVaildators(5);
|
||||
//是否需要校验,true是需要
|
||||
validator.AlwaysValidate = true;
|
||||
//校验单据头
|
||||
validator.EntityKey = "FBillHead";
|
||||
//加载校验器
|
||||
e.Validators.Add(validator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
using Kingdee.BOS;
|
||||
using ExtensionMethods;
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.App.Data;
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Util;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -12,15 +17,130 @@ namespace EastChanger.STK_StockCountLoss
|
||||
/// </summary>
|
||||
public class STKStockCountLossService : BaseService, ISynchonService
|
||||
{
|
||||
public STKStockCountLossService(Context context) : base(context, "", "海关信息同步")
|
||||
public STKStockCountLossService(Context context) : base(context, 5)
|
||||
{
|
||||
}
|
||||
|
||||
public string ModuleCnName => throw new NotImplementedException();
|
||||
|
||||
public void HandleSyncData(List<string> idList, IOperationResult opResult)
|
||||
public void HandleSyncData(List<string> idList, IOperationResult opResult, int action)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var declInfos = GetDeclInfos();
|
||||
|
||||
var whereSql = " AND FDOCUMENTSTATUS = 'C' ";
|
||||
if (action == 1)
|
||||
whereSql = " AND (SyncStatus = '1' OR SyncStatus = '-2') ";
|
||||
else
|
||||
whereSql += " AND SyncStatus != '1' ";
|
||||
|
||||
if (idList != null && idList.Any())
|
||||
whereSql += $" AND ID IN ({string.Join(",", idList)}) ";
|
||||
|
||||
var headSql = $@"
|
||||
SELECT * FROM V_SYNC_STKCOUNTLOSS
|
||||
WHERE 1 = 1
|
||||
{whereSql}
|
||||
";
|
||||
var entrySql = $@"
|
||||
SELECT * FROM V_SYNC_STKCOUNTLOSSENTRY
|
||||
WHERE 1 = 1
|
||||
{whereSql}
|
||||
";
|
||||
|
||||
var headList = DBUtils.ExecuteDynamicObject(_context, $"/*dialect*/{headSql}");
|
||||
var entryList = DBUtils.ExecuteDynamicObject(_context, $"/*dialect*/{entrySql}");
|
||||
|
||||
if (headList != null && headList.Any())
|
||||
{
|
||||
var groupList = entryList.GroupBy(x => x["ID"].ToString());
|
||||
|
||||
foreach (var head in headList)
|
||||
{
|
||||
var itemList = new List<Dictionary<string, object>>();
|
||||
var id = head["ID"].ToSafeTurnString();
|
||||
var bookNum = head["FBOOKNUM"].ToSafeTurnString();
|
||||
var syncStatus = head["SyncStatus"].Long2Int();
|
||||
|
||||
//申报类型
|
||||
var declaType = "";
|
||||
if (syncStatus == 1 || syncStatus == -2)
|
||||
declaType = "01";
|
||||
else
|
||||
declaType = "00";
|
||||
|
||||
//申报通用表头信息
|
||||
#region 表头信息
|
||||
var main = new Dictionary<string, object>(declInfos[bookNum]);
|
||||
main.Add("declaCode", id);
|
||||
main.Add("inventoryDt", head["inventoryDt"].ToSafeTurnString());
|
||||
main.Add("inputMan", head["inputMan"].ToSafeTurnString());
|
||||
main.Add("declaType", declaType);
|
||||
main.Add("busiType", "03");
|
||||
main.Add("inputDate", head["inputDate"].ToSafeTurnString());
|
||||
main.Add("declaDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
main.Add("itemList", itemList);
|
||||
#endregion
|
||||
|
||||
#region 表体信息
|
||||
var list = groupList.FirstOrDefault(w => w.Key == id);
|
||||
foreach (var entity in list.ToList())
|
||||
{
|
||||
var item = new Dictionary<string, object>();
|
||||
itemList.Add(item);
|
||||
item.Add("itemNo", entity["itemNo"].ToSafeTurnString());
|
||||
item.Add("materialCd", entity["materialCd"].ToSafeTurnString());
|
||||
item.Add("materialDesc", entity["materialDesc"].ToSafeTurnString());
|
||||
item.Add("materialType", entity["materialType"].ToSafeTurnString());
|
||||
item.Add("specificationsModels", entity["specificationsModels"].ToSafeTurnString());
|
||||
item.Add("adjmtrMarkcd", entity["adjmtrMarkcd"].ToSafeTurnString());
|
||||
item.Add("calcUnit", entity["calcUnit"].ToSafeTurnString());
|
||||
item.Add("cunit", entity["cunit"].ToSafeTurnString());
|
||||
item.Add("materialWarehouse", entity["materialWarehouse"].ToSafeTurnString());
|
||||
item.Add("erpWarehouse", entity["erpWarehouse"].ToSafeTurnString());
|
||||
item.Add("warehouseNumberDifference", entity["warehouseNumberDifference"].ToSafeTurnString());
|
||||
item.Add("erpWarehouseValue", entity["erpWarehouseValue"].ToSafeTurnString());
|
||||
item.Add("warehouseValuDifference", entity["warehouseValuDifference"].ToSafeTurnString());
|
||||
item.Add("currency", entity["currency"].ToSafeTurnString());
|
||||
item.Add("warehouseCd", entity["warehouseCd"].ToSafeTurnString());
|
||||
item.Add("warehousePosiCd", entity["warehousePosiCd"].ToSafeTurnString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
var dataJson = JsonUtil.Serialize(main);
|
||||
var result = this.DoSubmit(dataJson);
|
||||
|
||||
if (!result.IsNullOrEmpty())
|
||||
{
|
||||
JToken resData = JsonUtil.DeserializeObject<JToken>(result);
|
||||
var code = resData["code"].Long2Int();
|
||||
if (code == 0)
|
||||
{
|
||||
var data = resData["data"];
|
||||
var rtnFlag = data["rtnFlag"].Long2Int() == 0;
|
||||
var rtnMessage = data["rtnMessage"].ToString();
|
||||
UpdateStatus(this._context, id, (rtnFlag ? "1" : "-1"));
|
||||
ExecuteOperateResult(opResult, id, rtnMessage, rtnFlag);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus(this._context, id, "-1");
|
||||
ExecuteOperateResult(opResult, id, resData["msg"].ToString(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步完成后更新单据同步状态
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="status"></param>
|
||||
public void UpdateStatus(Context context, string id, string status)
|
||||
{
|
||||
var headSql = $@"UPDATE T_STK_STKCOUNTGAIN set FSTATUS='{status}' where FID = " + id;
|
||||
DBUtils.ExecuteDynamicObject(context, $"/*dialect*/{headSql}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user