2
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
using Kingdee.BOS;
|
||||
using EastChanger.Entites;
|
||||
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.Linq;
|
||||
@@ -20,7 +25,122 @@ namespace EastChanger.STK_Miscellaneous
|
||||
|
||||
public void HandleSyncData(List<string> idList, IOperationResult opResult, int action)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var declInfos = GetDeclInfos();
|
||||
var headSql = $@"
|
||||
SELECT
|
||||
rowSet.resVal AS ID
|
||||
INTO #TMPMATERIALNUM
|
||||
FROM (
|
||||
SELECT CAST('<v>'+ REPLACE('{string.Join(",", idList)}',',','</v><v>') + '</v>' AS XML) AS xmlVal
|
||||
) AS valSet
|
||||
OUTER APPLY (
|
||||
SELECT T.C.value('.','varchar(100)') resVal
|
||||
FROM valSet.xmlVal.nodes('/v') AS T(C)
|
||||
) rowSet
|
||||
|
||||
SELECT t1.ID EntityId,t2.FBILLNO AS EntityBillNo,t0.*
|
||||
FROM (SELECT t0.* FROM V_SYNC_STKMiscellaneous t0 WHERE 1 = 1 {{0}}) t0
|
||||
RIGHT JOIN #TMPMATERIALNUM t1 on t0.FID = t1.FID
|
||||
INNER JOIN T_STK_MISCELLANEOUS t2 on t2.FID = t1.FID
|
||||
";
|
||||
|
||||
var whereSql = "";
|
||||
if (action == 0)
|
||||
whereSql = " AND t0.SyncStatus != '-1' AND t0.SyncStatus != 1 ";
|
||||
else
|
||||
whereSql = " AND (t0.SyncStatus IN('-1','1')) ";
|
||||
|
||||
var toSql = string.Format(headSql, whereSql);
|
||||
//var toSql = headSql + whereSql;
|
||||
var dbList = DBUtils.ExecuteDynamicObject(_context, $"/*dialect*/{toSql}");
|
||||
if (dbList != null && dbList.Any())
|
||||
{
|
||||
var gbList = dbList.GroupBy(x => new Entities2GroupBy { BillNo = x["EntityBillNo"].ToString(), SyncStatus = x["FID"].Long2Int() > 0 });
|
||||
foreach (var bill in gbList)
|
||||
{
|
||||
|
||||
if (bill.Key.SyncStatus)
|
||||
ExecuteOperateResult(opResult, bill.Key.BillNo, "单据不符合同步条件,请检查单据状态", false);
|
||||
|
||||
var billNo = bill.Key.BillNo;
|
||||
var sort = 0;
|
||||
Dictionary<string, object> main = null;
|
||||
List<Dictionary<string, object>> itemList = new List<Dictionary<string, object>>();
|
||||
foreach (var entity in bill)
|
||||
{
|
||||
if (sort == 0)
|
||||
{
|
||||
var bookNum = entity["FBOOKNUM"].ToSafeTurnString();
|
||||
var syncStatus = entity["SyncStatus"].Long2Int();
|
||||
|
||||
//申报类型
|
||||
var declaType = "";
|
||||
if (action == 1)
|
||||
declaType = "99";
|
||||
else if (action == 2)
|
||||
declaType = "01";
|
||||
else
|
||||
declaType = "00";
|
||||
|
||||
main = new Dictionary<string, object>(declInfos[bookNum]);
|
||||
main.Add("declaCode", entity["FBILLNO"].ToSafeTurnString());
|
||||
main.Add("storageTm", entity["FINSTOCKDATE"].ToSafeTurnString());
|
||||
main.Add("storageType", entity["storageType"].ToSafeTurnString());
|
||||
main.Add("inputMan", entity["inputMan"].ToSafeTurnString());
|
||||
main.Add("busiType", "03");
|
||||
main.Add("declaType", declaType);
|
||||
main.Add("inputDate", entity["FDATE"].ToString());
|
||||
main.Add("declaDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
main.Add("itemList", itemList);
|
||||
sort++;
|
||||
}
|
||||
|
||||
var item = new Dictionary<string, object>();
|
||||
item.Add("itemNo", entity["itemNo"].ToString());
|
||||
item.Add("storageOrderNo", entity["itemNo"].ToString());
|
||||
item.Add("materialCd", entity["materialCd"].ToSafeTurnString());
|
||||
item.Add("materialDesc", entity["materialDesc"].ToSafeTurnString());
|
||||
item.Add("storageCnt", entity["storageCnt"].ToSafeTurnString());
|
||||
item.Add("calcUnit", entity["calcUnit"].ToSafeTurnString());
|
||||
item.Add("hscode", entity["hscode"].ToSafeTurnString());
|
||||
item.Add("inventory", entity["inventory"].ToSafeTurnString());
|
||||
item.Add("inventoryOrderNo", entity["inventoryOrderNo"].ToSafeTurnString());
|
||||
item.Add("warehouseCd", entity["warehouseCd"].ToSafeTurnString());
|
||||
item.Add("warehousePosiCd", entity["warehousePosiCd"].ToSafeTurnString());
|
||||
item.Add("bookSn", entity["bookSn"].ToSafeTurnString());
|
||||
itemList.Add(item);
|
||||
|
||||
}
|
||||
|
||||
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, billNo, rtnFlag ? "1" : (action == 0 ? "-2" : "-1"));
|
||||
ExecuteOperateResult(opResult, billNo, rtnMessage, rtnFlag);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus(this._context, billNo, action == 0 ? "-2" : "-1");
|
||||
ExecuteOperateResult(opResult, billNo, resData["msg"].ToString(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateStatus(Context context, string id, string status)
|
||||
{
|
||||
var headSql = @"UPDATE T_STK_MISCELLANEOUS set FSTATUS=" + status + " where FID = " + id;
|
||||
DBUtils.ExecuteDynamicObject(context, $"/*dialect*/{headSql}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user