2021-04-26 09:16:40 +08:00
|
|
|
|
using MSXML2;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2021-05-17 15:40:43 +08:00
|
|
|
|
using Dapper;
|
2021-04-26 09:16:40 +08:00
|
|
|
|
namespace NX.ERP.U8.Store
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MaterialAppVoucher : VoucherBase
|
|
|
|
|
|
{
|
2021-05-15 10:46:37 +08:00
|
|
|
|
public MaterialAppVoucher() : base("64", "U8API/AppVouchs")
|
2021-04-26 09:16:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AddVoucher(object param)
|
|
|
|
|
|
{
|
|
|
|
|
|
VoucherParameter voucherParameter = new VoucherParameter
|
|
|
|
|
|
{
|
|
|
|
|
|
VoucherType = this.VoucherID,
|
|
|
|
|
|
DomHead = new DOMDocumentClass(),
|
|
|
|
|
|
DomBody = new DOMDocumentClass()
|
|
|
|
|
|
};
|
|
|
|
|
|
DOMDocument domHead = voucherParameter.DomHead;
|
|
|
|
|
|
DOMDocument domBody = voucherParameter.DomBody;
|
|
|
|
|
|
voucherParameter.DomHead.loadXML(HeadTemplate);
|
|
|
|
|
|
voucherParameter.DomBody.loadXML(BodyTemplate);
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-17 15:40:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Model.Response.Store.MaterialApp> GetList(string strWhere = "", object Params = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var strSQL = @"select a.ID ,a.cCode as Code,a.dDate as Date,a.cMaker as PreparedBy,b.AutoID as id,b.AutoID as MaterialAppDtlId,
|
2021-05-19 13:55:55 +08:00
|
|
|
|
b.ID as MaterialAppId,b.cInvCode as MaterialCode,b.iQuantity as Quantit, b.imoseq as Pesodid,b.cmocode as MoCode,b.iMpoIds as AllocateId,b.fOutQuantity as OutQuantity from MaterialAppVouch a
|
|
|
|
|
|
left join
|
|
|
|
|
|
MaterialAppVouchs b on a.id=b.ID";
|
2021-05-17 15:40:43 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(strWhere))
|
|
|
|
|
|
{
|
|
|
|
|
|
strSQL += $" where {strWhere} ";
|
|
|
|
|
|
}
|
|
|
|
|
|
using (var conn = U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
|
|
|
|
|
var lookup = new Dictionary<int, Model.Response.Store.MaterialApp>();
|
|
|
|
|
|
conn.Query<Model.Response.Store.MaterialApp, Model.Response.Store.MaterialAppDetail, Model.Response.Store.MaterialApp>(strSQL, (head, body) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!lookup.TryGetValue(head.Id, out var _head))
|
|
|
|
|
|
{
|
|
|
|
|
|
lookup.Add(head.Id, head);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
head = _head;
|
|
|
|
|
|
}
|
|
|
|
|
|
head.MaterialAppVouchsLst.Add(body);
|
|
|
|
|
|
return head;
|
|
|
|
|
|
}, Params, null, true, "id", 10, System.Data.CommandType.Text); ;
|
|
|
|
|
|
return lookup.Values;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-05-19 13:55:55 +08:00
|
|
|
|
/// 查询等待未完成可出库的单子
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public IEnumerable<Model.Response.Store.MaterialApp> GetPendingList()
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.GetList(" b.cDefine22='是' and iQuantity<>ISNULL( fOutQuantity,0)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取
|
2021-05-17 15:40:43 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Code"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Model.Response.Store.MaterialApp GetModel(string Code)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.GetList(" a.cCode=@Code", new { Code }).FirstOrDefault();
|
2021-05-18 15:16:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="MoCode"></param>
|
|
|
|
|
|
/// <param name="MoDetailId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Model.Response.Store.MaterialApp> GetListByMoCode(string MoCode, int MoDetailId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.GetList(@" b.cmocode=@MoCode and
|
|
|
|
|
|
b.iMPoIds in (
|
|
|
|
|
|
select AllocateId from mom_moallocate where MoDId = @MoDetailId) ", new { MoCode, MoDetailId });
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-17 15:40:43 +08:00
|
|
|
|
|
2021-05-18 15:16:31 +08:00
|
|
|
|
public IEnumerable<Model.Response.Store.MaterialAppDetail> GetDetailByMoCode(string MoCode, int MoDetailId)
|
|
|
|
|
|
{
|
|
|
|
|
|
var models = this.GetListByMoCode(MoCode, MoDetailId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reslut = new List<Model.Response.Store.MaterialAppDetail>();
|
|
|
|
|
|
foreach (var items in models)
|
|
|
|
|
|
{
|
|
|
|
|
|
reslut.AddRange(items.MaterialAppVouchsLst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return reslut;
|
2021-05-17 15:40:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-18 15:16:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Provide(NX.ERP.Model.Request.MaterialAppProvide provide)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var conn = U8LoginContext.Instance.Connection)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = @"update MaterialAppVouchs set dDueDate=@DueDate,cDefine22='是',cDefine23=@SN,cDefine24=@WorkCenter";
|
|
|
|
|
|
if (provide.Detail1.Count() != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mappDetails = this.GetDetailByMoCode(provide.OrderCode, provide.OrderDetailId).ToDictionary(m => m.AllocateId);
|
|
|
|
|
|
foreach (var item in provide.Detail1)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mappDetails.TryGetValue(item.AllocateId, out var _mappDetails))
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("未找到");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else //整单发出
|
|
|
|
|
|
{
|
|
|
|
|
|
strSql = @"update MaterialAppVouchs set dDueDate=@DueDate,cDefine22='是',cDefine23=@SN,cDefine24=@WorkCenter where cmocode = @MoCode and
|
|
|
|
|
|
iMPoIds in (
|
|
|
|
|
|
select AllocateId from mom_moallocate where MoDId = @OrderDetailId
|
|
|
|
|
|
)";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.Execute(strSql, new
|
|
|
|
|
|
{
|
2021-05-19 13:55:55 +08:00
|
|
|
|
DueDate = provide.DueDate,
|
|
|
|
|
|
SN ="",
|
2021-05-18 15:16:31 +08:00
|
|
|
|
WorkCenter = provide.WorkCenter,
|
|
|
|
|
|
MoCode = provide.OrderCode,
|
|
|
|
|
|
OrderDetailId = provide.OrderDetailId
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-04-26 09:16:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|