解决直接调拨单合并的问题,新建2个文件重构代码,目前没有使用这2个文件
This commit is contained in:
@@ -13,6 +13,7 @@ using RB_MES_API.Controllers.Cloud;
|
|||||||
using RB_MES_API.Models;
|
using RB_MES_API.Models;
|
||||||
using RB_MES_API.Models.Cloud;
|
using RB_MES_API.Models.Cloud;
|
||||||
using RB_MES_API.Models.Pangu;
|
using RB_MES_API.Models.Pangu;
|
||||||
|
using RB_MES_APICore.Controllers.Interface;
|
||||||
using RB_MES_APICore.Models;
|
using RB_MES_APICore.Models;
|
||||||
using RB_MES_APICore.Models.Cloud;
|
using RB_MES_APICore.Models.Cloud;
|
||||||
using RB_MES_APICore.Models.Pangu;
|
using RB_MES_APICore.Models.Pangu;
|
||||||
@@ -43,6 +44,7 @@ namespace RB_MES_API.Controllers
|
|||||||
private delegate Task<string> _PugAsync(Dictionary<string, object> pairs, CloudBillQuery billquery);
|
private delegate Task<string> _PugAsync(Dictionary<string, object> pairs, CloudBillQuery billquery);
|
||||||
private delegate Task<BreakData> _SaveAsync<T>(string formid, T inputdata) where T : class;
|
private delegate Task<BreakData> _SaveAsync<T>(string formid, T inputdata) where T : class;
|
||||||
public delegate Task<int> _SaveReciveDataBackAsync(List<ReciveDataBack> dataBacks);
|
public delegate Task<int> _SaveReciveDataBackAsync(List<ReciveDataBack> dataBacks);
|
||||||
|
//private IMesApiSTKTransferDirectsService _STKTransferDirectsService;
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 需要查询的请求列表
|
///// 需要查询的请求列表
|
||||||
///// </summary>
|
///// </summary>
|
||||||
@@ -56,13 +58,14 @@ namespace RB_MES_API.Controllers
|
|||||||
/// <param name="chiledSelect"></param>
|
/// <param name="chiledSelect"></param>
|
||||||
/// <param name="kdsqlhelper"></param>
|
/// <param name="kdsqlhelper"></param>
|
||||||
public EnpowerApiController(RBContext context, IShareController shareController, IKDCloudHttpClient kdhttpClient,
|
public EnpowerApiController(RBContext context, IShareController shareController, IKDCloudHttpClient kdhttpClient,
|
||||||
IChiledSelect chiledSelect, IKDSqlHelper kdsqlhelper)
|
IChiledSelect chiledSelect, IKDSqlHelper kdsqlhelper )
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_shareController = shareController;
|
_shareController = shareController;
|
||||||
_KdhttpClient = kdhttpClient;
|
_KdhttpClient = kdhttpClient;
|
||||||
_chiledselect = chiledSelect;
|
_chiledselect = chiledSelect;
|
||||||
_kdsqlhelper = kdsqlhelper;
|
_kdsqlhelper = kdsqlhelper;
|
||||||
|
//_STKTransferDirectsService = STKTransferDirectsService;
|
||||||
//_pushmesinterface = pushmesinterface;
|
//_pushmesinterface = pushmesinterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6243,7 +6246,7 @@ namespace RB_MES_API.Controllers
|
|||||||
/// <param name="billtype">FBillTypeID的FNumber属性</param>
|
/// <param name="billtype">FBillTypeID的FNumber属性</param>
|
||||||
/// <param name="reason">如果错误,则返回消息</param>
|
/// <param name="reason">如果错误,则返回消息</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private List<STK_TransferDirect> CreateBatchSTKTransferDirects(List<R011> R011cs, string billtype, ref string reason)
|
private List<STK_TransferDirect> CreateBatchSTKTransferDirectsOLD(List<R011> R011cs, string billtype, ref string reason)
|
||||||
{
|
{
|
||||||
reason = "";
|
reason = "";
|
||||||
List<STK_TransferDirect> list = new List<STK_TransferDirect>();
|
List<STK_TransferDirect> list = new List<STK_TransferDirect>();
|
||||||
@@ -6313,6 +6316,8 @@ namespace RB_MES_API.Controllers
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建VMI调拨单信息,并转换成Cloud的实体类
|
/// 创建VMI调拨单信息,并转换成Cloud的实体类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -7199,6 +7204,7 @@ namespace RB_MES_API.Controllers
|
|||||||
}
|
}
|
||||||
return breakData;
|
return breakData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提供批量保存、提交并审核普通生产补料单
|
/// 提供批量保存、提交并审核普通生产补料单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -11252,6 +11258,165 @@ namespace RB_MES_API.Controllers
|
|||||||
}
|
}
|
||||||
#endregion 推送操作检测
|
#endregion 推送操作检测
|
||||||
|
|
||||||
|
private List<STK_TransferDirect> CreateBatchSTKTransferDirects(List<R011> R011cs, string billtype, ref string reason)
|
||||||
|
{
|
||||||
|
reason = "";
|
||||||
|
List<STK_TransferDirect> list = new List<STK_TransferDirect>();
|
||||||
|
var R011 = (from a in R011cs
|
||||||
|
group a by a.TRX_DATE into b
|
||||||
|
select b).Distinct().ToList();
|
||||||
|
|
||||||
|
List<BD_UNIT> units = _shareController.GetAPIList<BD_UNIT>().Result;
|
||||||
|
foreach (var head in R011)
|
||||||
|
{
|
||||||
|
//创建单据头
|
||||||
|
STK_TransferDirect inStock = new()
|
||||||
|
{
|
||||||
|
FBillTypeID = new Dictionary<string, string>() { { "FNUMBER", billtype } },
|
||||||
|
FDate = head.Key,
|
||||||
|
FOwnerOutIdHead = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } },
|
||||||
|
F_SBMI_QUEUE_ID = string.Format("R011:{0}", R011cs.FirstOrDefault().QUEUE_ID) //如果不是盘古,建议放在单据体!!!
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//收集物料清单,一起查询
|
||||||
|
var mary = from a in R011cs select a.MTRL_ID;
|
||||||
|
List<BD_Material> marylist = _chiledselect.materialsAsync(mary.ToList()).Result;
|
||||||
|
if (marylist.Count == 0)
|
||||||
|
{
|
||||||
|
reason = "输入的物料编码不存在";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先进行分组汇总,再构建单据体
|
||||||
|
var groupedData = (from b in R011cs
|
||||||
|
join c in marylist on b.MTRL_ID equals c.FNumber
|
||||||
|
join d in units on c.FStoreUnitID equals d.FUNITID
|
||||||
|
join e in units on c.FBaseUnitId equals e.FUNITID
|
||||||
|
group new { b, c, d, e } by new
|
||||||
|
{
|
||||||
|
b.MTRL_ID,
|
||||||
|
b.ERP_LOTNO,
|
||||||
|
b.STORE_ID,
|
||||||
|
b.TOSTORE_ID,
|
||||||
|
c.FUnitNumber,
|
||||||
|
c.FBaseUnitNumber,
|
||||||
|
b.REMARK,
|
||||||
|
b.MTRL_VER,
|
||||||
|
d.FConvertNumerator,
|
||||||
|
d.FConvertDenominator,
|
||||||
|
d.FPrecision
|
||||||
|
} into g
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
MTRL_ID = g.Key.MTRL_ID,
|
||||||
|
ERP_LOTNO = g.Key.ERP_LOTNO,
|
||||||
|
STORE_ID = g.Key.STORE_ID,
|
||||||
|
TOSTORE_ID = g.Key.TOSTORE_ID,
|
||||||
|
FUnitNumber = g.Key.FUnitNumber,
|
||||||
|
FBaseUnitNumber = g.Key.FBaseUnitNumber,
|
||||||
|
REMARK = g.Key.REMARK,
|
||||||
|
MTRL_VER = g.Key.MTRL_VER,
|
||||||
|
FConvertNumerator = g.Key.FConvertNumerator,
|
||||||
|
FConvertDenominator = g.Key.FConvertDenominator,
|
||||||
|
FPrecision = g.Key.FPrecision,
|
||||||
|
// 累加数量
|
||||||
|
TotalQuantity = g.Sum(x => SafeParseDecimal(x.b.QUANTITY)),
|
||||||
|
// 取第一条记录的物料信息(假设相同物料的其他信息一致)
|
||||||
|
MaterialInfo = g.First().c,
|
||||||
|
UnitInfo = g.First().d
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// 构建单据体
|
||||||
|
List<STK_TransferDirect.BillEntry> entries = groupedData.Select(g =>
|
||||||
|
{
|
||||||
|
var quantity = g.TotalQuantity;
|
||||||
|
var conversionRate = (g.FConvertDenominator == 0) ? 1 : g.FConvertNumerator / g.FConvertDenominator;
|
||||||
|
var baseQty = Math.Round(quantity / conversionRate, g.FPrecision);
|
||||||
|
|
||||||
|
return new STK_TransferDirect.BillEntry
|
||||||
|
{
|
||||||
|
FMaterialId = CreateDictionary("FNumber", g.MTRL_ID),
|
||||||
|
FNoteEntry = g.REMARK,
|
||||||
|
FLot = CreateDictionary("FNumber", g.ERP_LOTNO),
|
||||||
|
FDestLot = CreateDictionary("FNumber", g.ERP_LOTNO),
|
||||||
|
FQty = quantity,
|
||||||
|
FDestStockId = CreateDictionary("FNumber", g.TOSTORE_ID),
|
||||||
|
FUnitID = CreateDictionary("FNumber", g.FUnitNumber),
|
||||||
|
FBaseUnitId = CreateDictionary("FNumber", g.FBaseUnitNumber),
|
||||||
|
FSrcStockId = CreateDictionary("FNumber", g.STORE_ID),
|
||||||
|
FSaleQty = quantity,
|
||||||
|
FSaleUnitId = CreateDictionary("FNumber", g.FUnitNumber),
|
||||||
|
FActQty = quantity,
|
||||||
|
FSalBaseQty = baseQty,
|
||||||
|
FBaseQty = baseQty,
|
||||||
|
FOwnerOutId = CreateDictionary("FNumber", LocalStaticRequest.DefaultOrg),
|
||||||
|
FAuxPropId = string.IsNullOrEmpty(g.MTRL_VER) ? null :
|
||||||
|
new STK_TransferDirect.BillEntry.AuxpropId()
|
||||||
|
{
|
||||||
|
FAUXPROPID__FF100001 = CreateDictionary("FNumber", g.MTRL_VER)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
////添加单据体,按订单号找到它的明细数据
|
||||||
|
//List<STK_TransferDirect.BillEntry> entries = (from a in head
|
||||||
|
// join b in R011cs on a.TRX_DATE equals b.TRX_DATE
|
||||||
|
// join c in marylist on b.MTRL_ID equals c.FNumber
|
||||||
|
// join d in units on c.FStoreUnitID equals d.FUNITID
|
||||||
|
// join e in units on c.FBaseUnitId equals e.FUNITID
|
||||||
|
// select new STK_TransferDirect.BillEntry
|
||||||
|
// {
|
||||||
|
// FMaterialId = new Dictionary<string, string>() { { "FNumber", b.MTRL_ID } },
|
||||||
|
// FNoteEntry = b.REMARK,
|
||||||
|
// FLot = new Dictionary<string, string>() { { "FNumber", b.ERP_LOTNO } },
|
||||||
|
// FDestLot = new Dictionary<string, string>() { { "FNumber", b.ERP_LOTNO } },
|
||||||
|
// FQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FDestStockId = new Dictionary<string, string>() { { "FNumber", b.TOSTORE_ID } },
|
||||||
|
// FUnitID = new Dictionary<string, string>() { { "FNumber", c.FUnitNumber } },
|
||||||
|
// FBaseUnitId = new Dictionary<string, string>() { { "FNumber", c.FBaseUnitNumber } },
|
||||||
|
// FSrcStockId = new Dictionary<string, string>() { { "FNumber", b.STORE_ID } },
|
||||||
|
// FSaleQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FSaleUnitId = new Dictionary<string, string>() { { "FNumber", c.FUnitNumber } },
|
||||||
|
// FActQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FSalBaseQty = Math.Round(decimal.Parse(b.QUANTITY) / (d.FConvertNumerator / d.FConvertDenominator), d.FPrecision),
|
||||||
|
// FBaseQty = Math.Round(decimal.Parse(b.QUANTITY) / (d.FConvertNumerator / d.FConvertDenominator), d.FPrecision),
|
||||||
|
// FOwnerOutId = new Dictionary<string, string>() { { "FNumber", LocalStaticRequest.DefaultOrg } },
|
||||||
|
// FAuxPropId = string.IsNullOrEmpty(b.MTRL_VER) ? null : new STK_TransferDirect.BillEntry.AuxpropId() { FAUXPROPID__FF100001 = new Dictionary<string, string>() { { "FNumber", b.MTRL_VER } } }
|
||||||
|
// }
|
||||||
|
// ).Distinct().ToList()
|
||||||
|
// ;
|
||||||
|
var q = entries.Where(s => s.FQty <= 0).ToList();
|
||||||
|
if (q.Count > 0)
|
||||||
|
{
|
||||||
|
reason = "入库单数量必须大于0";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
string s = JsonConvert.SerializeObject(entries);
|
||||||
|
inStock.FBillEntry = entries;
|
||||||
|
//财务费用,隶属于单据体
|
||||||
|
list.Add(inStock);
|
||||||
|
|
||||||
|
}
|
||||||
|
////先将返回数据格式化
|
||||||
|
//string jobj = JsonConvert.SerializeObject(list);
|
||||||
|
//LogHelper.WriteLog("直接调拨单的合并数据处理结果:"+ jobj);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 安全解析decimal的辅助方法
|
||||||
|
private decimal SafeParseDecimal(string value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
return 0m;
|
||||||
|
|
||||||
|
return decimal.TryParse(value, out decimal result) ? result : 0m;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建字典的辅助方法
|
||||||
|
private Dictionary<string, string> CreateDictionary(string key, string value)
|
||||||
|
{
|
||||||
|
return new Dictionary<string, string> { { key, value ?? string.Empty } };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
Controllers/Interface/IMesApiSTKTransferDirectsService.cs
Normal file
15
Controllers/Interface/IMesApiSTKTransferDirectsService.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using RB_MES_API.Models.Cloud;
|
||||||
|
using RB_MES_API.Models.Pangu;
|
||||||
|
using RB_MES_APICore.Models.Cloud;
|
||||||
|
using RB_MES_APICore.Models.Pangu;
|
||||||
|
|
||||||
|
namespace RB_MES_API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 直接调拨单:STK_TRANSFERDIRECT 相关业务
|
||||||
|
/// </summary>
|
||||||
|
public interface IMesApiSTKTransferDirectsService
|
||||||
|
{
|
||||||
|
//List<STK_TransferDirect> CreateBatchSTKTransferDirects(List<R011> R011cs, string billtype, ref string reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
301
Controllers/Interface/MesApiSTKTransferDirectsService.cs
Normal file
301
Controllers/Interface/MesApiSTKTransferDirectsService.cs
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RB_MES_API.Context;
|
||||||
|
using RB_MES_API.Controllers;
|
||||||
|
using RB_MES_API.Controllers.Cloud;
|
||||||
|
using RB_MES_API.Models;
|
||||||
|
using RB_MES_API.Models.Cloud;
|
||||||
|
using RB_MES_APICore.Models.Pangu;
|
||||||
|
using System.Data;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace RB_MES_APICore.Controllers.Interface
|
||||||
|
{
|
||||||
|
public class MesApiSTKTransferDirectsService : IMesApiSTKTransferDirectsService
|
||||||
|
{
|
||||||
|
private readonly IShareController _shareController;
|
||||||
|
private readonly IChiledSelect _chiledselect;
|
||||||
|
private readonly IKDSqlHelper _kdsqlhelper;
|
||||||
|
public MesApiSTKTransferDirectsService(IShareController shareController, IChiledSelect chiledSelect, IKDSqlHelper kdsqlhelper )
|
||||||
|
{
|
||||||
|
_shareController = shareController;
|
||||||
|
_chiledselect = chiledSelect;
|
||||||
|
_kdsqlhelper = kdsqlhelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//private async Task<BreakData> SaveBatchSTKTransferDirectsAsync(DataTable dataTable, int fid, int postmid, string data)
|
||||||
|
//{
|
||||||
|
// BreakData breakData = new BreakData() { Status = false, DataSet = JsonConvert.DeserializeObject(data) };
|
||||||
|
// string reason = string.Empty;
|
||||||
|
// List<R011>? mes_POInStocks = _shareController.DataConvertClass<R011>(data, ref reason);
|
||||||
|
// if (mes_POInStocks != null)
|
||||||
|
// {
|
||||||
|
// //推送数据
|
||||||
|
// var dsb = await _shareController.GetAPIList<DataSaveBatch>();
|
||||||
|
// DataSaveBatch? dataSave = dsb.Where(s => s.GetForm.FFunctionID == fid && s.FDocTypeID == postmid)
|
||||||
|
// .FirstOrDefault();
|
||||||
|
// breakData.Message = string.Empty;
|
||||||
|
// //校验是否有重复推单
|
||||||
|
// breakData = ExistsDoubleQueid(mes_POInStocks, dataSave.GetForm.FDocType);
|
||||||
|
// if (breakData.Status || !string.IsNullOrEmpty(breakData.Message.ToString()))
|
||||||
|
// {
|
||||||
|
// return breakData;
|
||||||
|
// }
|
||||||
|
// List<STK_TransferDirect> inStocks = CreateBatchSTKTransferDirects(mes_POInStocks, dataSave.FErpBillType, ref reason);
|
||||||
|
|
||||||
|
// if (inStocks.Count() > 0 && reason == "")
|
||||||
|
// {
|
||||||
|
// breakData = await SaveBatchAsync(dataSave, dataSave.GetForm.FDBName, inStocks);
|
||||||
|
// if (breakData.Status)
|
||||||
|
// {
|
||||||
|
// List<ReciveDataBack> dataBacks = new List<ReciveDataBack>();
|
||||||
|
// if (breakData.DataSet != null)
|
||||||
|
// {
|
||||||
|
// //提取出创建好的单据编号
|
||||||
|
// List<Dictionary<string, string>> billlist = (List<Dictionary<string, string>>)breakData.DataSet;
|
||||||
|
// List<string> billnolist = GetNewBillNoList(dataSave.GetForm.FDocType, mes_POInStocks, billlist, ref dataBacks);
|
||||||
|
// Thread thread = new Thread(_shareController.SaveReciveData);
|
||||||
|
// //thread_1.IsBackground = true; //这意味着主程序可能不等它保存了...
|
||||||
|
// thread.Start(dataBacks);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// dataBacks = await DataBacks(postmid, mes_POInStocks);
|
||||||
|
// if (dataBacks.Count != 0)
|
||||||
|
// {
|
||||||
|
// Thread thread_1 = new Thread(_shareController.SaveReciveData);
|
||||||
|
// //thread_1.IsBackground = true; //这意味着主程序可能不等它保存了...
|
||||||
|
// thread_1.Start(dataBacks);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Status = false;
|
||||||
|
// breakData.Message = "不可控因素,请稍后再次提交";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// breakData.DataSet = dataBacks;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = reason;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = string.IsNullOrEmpty(reason) ? "输入数据转换出错" : reason;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return breakData;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 创建调拨单信息,并转换成Cloud的实体类
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="R011cs">接收到的数据</param>
|
||||||
|
///// <param name="billtype">FBillTypeID的FNumber属性</param>
|
||||||
|
///// <param name="reason">如果错误,则返回消息</param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public List<STK_TransferDirect> CreateBatchSTKTransferDirects(List<R011> R011cs, string billtype, ref string reason)
|
||||||
|
//{
|
||||||
|
// reason = "";
|
||||||
|
// List<STK_TransferDirect> list = new List<STK_TransferDirect>();
|
||||||
|
// var R011 = (from a in R011cs
|
||||||
|
// group a by a.TRX_DATE into b
|
||||||
|
// select b).Distinct().ToList();
|
||||||
|
|
||||||
|
// List<BD_UNIT> units = _shareController.GetAPIList<BD_UNIT>().Result;
|
||||||
|
// foreach (var head in R011)
|
||||||
|
// {
|
||||||
|
// //创建单据头
|
||||||
|
// STK_TransferDirect inStock = new()
|
||||||
|
// {
|
||||||
|
// FBillTypeID = new Dictionary<string, string>() { { "FNUMBER", billtype } },
|
||||||
|
// FDate = head.Key,
|
||||||
|
// FOwnerOutIdHead = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } },
|
||||||
|
// F_SBMI_QUEUE_ID = string.Format("R011:{0}", R011cs.FirstOrDefault().QUEUE_ID) //如果不是盘古,建议放在单据体!!!
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
// //收集物料清单,一起查询
|
||||||
|
// var mary = from a in R011cs select a.MTRL_ID;
|
||||||
|
// List<BD_Material> marylist = _chiledselect.materialsAsync(mary.ToList()).Result;
|
||||||
|
// if (marylist.Count == 0)
|
||||||
|
// {
|
||||||
|
// reason = "输入的物料编码不存在";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// //添加单据体,按订单号找到它的明细数据
|
||||||
|
// List<STK_TransferDirect.BillEntry> entries = (from a in head
|
||||||
|
// join b in R011cs on a.TRX_DATE equals b.TRX_DATE
|
||||||
|
// join c in marylist on b.MTRL_ID equals c.FNumber
|
||||||
|
// join d in units on c.FStoreUnitID equals d.FUNITID
|
||||||
|
// join e in units on c.FBaseUnitId equals e.FUNITID
|
||||||
|
// select new STK_TransferDirect.BillEntry
|
||||||
|
// {
|
||||||
|
// FMaterialId = new Dictionary<string, string>() { { "FNumber", b.MTRL_ID } },
|
||||||
|
// FNoteEntry = b.REMARK,
|
||||||
|
// FLot = new Dictionary<string, string>() { { "FNumber", b.ERP_LOTNO } },
|
||||||
|
// FDestLot = new Dictionary<string, string>() { { "FNumber", b.ERP_LOTNO } },
|
||||||
|
// FQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FDestStockId = new Dictionary<string, string>() { { "FNumber", b.TOSTORE_ID } },
|
||||||
|
// FUnitID = new Dictionary<string, string>() { { "FNumber", c.FUnitNumber } },
|
||||||
|
// FBaseUnitId = new Dictionary<string, string>() { { "FNumber", c.FBaseUnitNumber } },
|
||||||
|
// FSrcStockId = new Dictionary<string, string>() { { "FNumber", b.STORE_ID } },
|
||||||
|
// FSaleQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FSaleUnitId = new Dictionary<string, string>() { { "FNumber", c.FUnitNumber } },
|
||||||
|
// FActQty = decimal.Parse(b.QUANTITY),
|
||||||
|
// FSalBaseQty = Math.Round(decimal.Parse(b.QUANTITY) / (d.FConvertNumerator / d.FConvertDenominator), d.FPrecision),
|
||||||
|
// FBaseQty = Math.Round(decimal.Parse(b.QUANTITY) / (d.FConvertNumerator / d.FConvertDenominator), d.FPrecision),
|
||||||
|
// FOwnerOutId = new Dictionary<string, string>() { { "FNumber", LocalStaticRequest.DefaultOrg } },
|
||||||
|
// FAuxPropId = string.IsNullOrEmpty(b.MTRL_VER) ? null : new STK_TransferDirect.BillEntry.AuxpropId() { FAUXPROPID__FF100001 = new Dictionary<string, string>() { { "FNumber", b.MTRL_VER } } }
|
||||||
|
// }
|
||||||
|
// ).Distinct().ToList()
|
||||||
|
// ;
|
||||||
|
// var q = entries.Where(s => s.FQty <= 0).ToList();
|
||||||
|
// if (q.Count > 0)
|
||||||
|
// {
|
||||||
|
// reason = "入库单数量必须大于0";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// string s = JsonConvert.SerializeObject(entries);
|
||||||
|
// inStock.FBillEntry = entries;
|
||||||
|
// //财务费用,隶属于单据体
|
||||||
|
// list.Add(inStock);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// return list;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public async Task<BreakData> SaveBatchSTKTransferDirectsAsync(DataTable dataTable, int fid, int postmid, string data)
|
||||||
|
//{
|
||||||
|
// BreakData breakData = new BreakData() { Status = false, DataSet = JsonConvert.DeserializeObject(data) };
|
||||||
|
// string reason = string.Empty;
|
||||||
|
// List<R011>? mes_POInStocks = _shareController.DataConvertClass<R011>(data, ref reason);
|
||||||
|
// if (mes_POInStocks != null)
|
||||||
|
// {
|
||||||
|
// //推送数据
|
||||||
|
// var dsb = await _shareController.GetAPIList<DataSaveBatch>();
|
||||||
|
// DataSaveBatch? dataSave = dsb.Where(s => s.GetForm.FFunctionID == fid && s.FDocTypeID == postmid)
|
||||||
|
// .FirstOrDefault();
|
||||||
|
// breakData.Message = string.Empty;
|
||||||
|
// //校验是否有重复推单
|
||||||
|
// breakData = ExistsDoubleQueid(mes_POInStocks, dataSave.GetForm.FDocType);
|
||||||
|
// if (breakData.Status || !string.IsNullOrEmpty(breakData.Message.ToString()))
|
||||||
|
// {
|
||||||
|
// return breakData;
|
||||||
|
// }
|
||||||
|
// List<STK_TransferDirect> inStocks = CreateBatchSTKTransferDirects(mes_POInStocks, dataSave.FErpBillType, ref reason);
|
||||||
|
|
||||||
|
// if (inStocks.Count() > 0 && reason == "")
|
||||||
|
// {
|
||||||
|
// breakData = await SaveBatchAsync(dataSave, dataSave.GetForm.FDBName, inStocks);
|
||||||
|
// if (breakData.Status)
|
||||||
|
// {
|
||||||
|
// List<ReciveDataBack> dataBacks = new List<ReciveDataBack>();
|
||||||
|
// if (breakData.DataSet != null)
|
||||||
|
// {
|
||||||
|
// //提取出创建好的单据编号
|
||||||
|
// List<Dictionary<string, string>> billlist = (List<Dictionary<string, string>>)breakData.DataSet;
|
||||||
|
// List<string> billnolist = GetNewBillNoList(dataSave.GetForm.FDocType, mes_POInStocks, billlist, ref dataBacks);
|
||||||
|
// Thread thread = new Thread(_shareController.SaveReciveData);
|
||||||
|
// //thread_1.IsBackground = true; //这意味着主程序可能不等它保存了...
|
||||||
|
// thread.Start(dataBacks);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// dataBacks = await DataBacks(postmid, mes_POInStocks);
|
||||||
|
// if (dataBacks.Count != 0)
|
||||||
|
// {
|
||||||
|
// Thread thread_1 = new Thread(_shareController.SaveReciveData);
|
||||||
|
// //thread_1.IsBackground = true; //这意味着主程序可能不等它保存了...
|
||||||
|
// thread_1.Start(dataBacks);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Status = false;
|
||||||
|
// breakData.Message = "不可控因素,请稍后再次提交";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// breakData.DataSet = dataBacks;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = reason;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = string.IsNullOrEmpty(reason) ? "输入数据转换出错" : reason;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return breakData;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private BreakData ExistsDoubleQueid<T>(List<T> inputdata, string DocType) where T : class
|
||||||
|
//{
|
||||||
|
// BreakData breakData = new BreakData() { Status = false };
|
||||||
|
// //return breakData;
|
||||||
|
// Type type = typeof(T);
|
||||||
|
// PropertyInfo[] propertyInfos = type.GetProperties();
|
||||||
|
// var propertyInfo = propertyInfos.Where(s => s.Name == "QUEUE_ID");
|
||||||
|
// if (propertyInfo.Any())
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// List<string> strings = new List<string>();
|
||||||
|
// PropertyInfo infos = propertyInfo.FirstOrDefault()!;
|
||||||
|
// foreach (var obj in inputdata)
|
||||||
|
// {
|
||||||
|
// object v = infos.GetValue(obj)!;
|
||||||
|
// strings.Add(string.Format("'{0}'", v.ToString()));
|
||||||
|
// }
|
||||||
|
// string sql = string.Format("select * from r_ReciveDataBack where FDocType='{0}' and QUEUE_ID in ({1})", DocType, string.Join(',', strings.ToArray()));
|
||||||
|
// //直接SQL查询更快!!!
|
||||||
|
// string messstr = string.Empty;
|
||||||
|
// DataSet? dataSet = _kdsqlhelper.GetDataSet(CommandType.Text, sql, null, ref messstr!, false);
|
||||||
|
// if (dataSet != null || string.IsNullOrEmpty(messstr))
|
||||||
|
// {
|
||||||
|
// if (dataSet.Tables.Count != 0)
|
||||||
|
// {
|
||||||
|
// DataTable dataTable = dataSet.Tables[0];
|
||||||
|
// if (dataTable.Rows.Count != 0)
|
||||||
|
// {
|
||||||
|
// breakData.Status = true;
|
||||||
|
// breakData.Message = "不可重复推单";
|
||||||
|
// var dt = (from a in dataTable.AsEnumerable()
|
||||||
|
// select new
|
||||||
|
// {
|
||||||
|
// QUEUE_ID = a.Field<string>("QUEUE_ID").ToString(),
|
||||||
|
// FDocType = a.Field<string>("FDocType")!,
|
||||||
|
// FBillNo = a.Field<string>("FBillNo")!,
|
||||||
|
// FErpID = a.Field<int>("FErpID"),
|
||||||
|
// FSeq = a.Field<int>("FSeq")
|
||||||
|
// }).ToList();
|
||||||
|
// breakData.DataSet = dt;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = messstr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// breakData.Message = "错误在ExistsDoubleQueid中发生:" + ex.Message;
|
||||||
|
// //throw;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// breakData.Message = "传入的数据中必须有字段【QUEUE_ID】";
|
||||||
|
// }
|
||||||
|
// return breakData;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user