添加领料申请

This commit is contained in:
gongxh
2021-05-17 15:40:43 +08:00
parent e5774f9b86
commit 1c32ca4a40
8 changed files with 310 additions and 154 deletions

View File

@@ -69,6 +69,7 @@
<Compile Include="Request\SaleOrderRequest.cs" /> <Compile Include="Request\SaleOrderRequest.cs" />
<Compile Include="Response\MOM\Bom.cs" /> <Compile Include="Response\MOM\Bom.cs" />
<Compile Include="Response\Pmc\PmcInventoryallRes.cs" /> <Compile Include="Response\Pmc\PmcInventoryallRes.cs" />
<Compile Include="Response\Store\MaterialApp.cs" />
<Compile Include="Response\Store\Stock.cs" /> <Compile Include="Response\Store\Stock.cs" />
<Compile Include="TimestampConverter.cs" /> <Compile Include="TimestampConverter.cs" />
<Compile Include="Request\Arrival.cs" /> <Compile Include="Request\Arrival.cs" />

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Response.Store
{
// {
// "MaterialAppVouchs_lst": [
// {
// "MaterialApp_dtl_id": 1000009219,
// "MaterialApp_id": 1000002408,
// "material_code": "524020",
// "qty": 1,
// "ipesodid": 1000009219,
// },
// "MaterialApp_id": 1000002408,
// "cCode": "LLSQ201000089",
// "dDate": "2021-01-03T00:00:00+08:00",
// "prepared_by": "王",
// }
//]
public class MaterialAppDetail
{
private int materialAppDtlId;
private int materialAppId;
private string materialCode;
private decimal qty;
private int pesodid;
public int MaterialAppDtlId { get => materialAppDtlId; set => materialAppDtlId = value; }
public int MaterialAppId { get => materialAppId; set => materialAppId = value; }
public string MaterialCode { get => materialCode; set => materialCode = value; }
public decimal Qty { get => qty; set => qty = value; }
public int Pesodid { get => pesodid; set => pesodid = value; }
}
/// <summary>
///
/// </summary>
public class MaterialApp
{
private int id;
private string code;
private DateTime date;
private string preparedBy;
private ICollection<MaterialAppDetail> materialAppVouchsLst = new List<MaterialAppDetail>();
public int Id { get => id; set => id = value; }
public string Code { get => code; set => code = value; }
public DateTime Date { get => date; set => date = value; }
public string PreparedBy { get => preparedBy; set => preparedBy = value; }
public ICollection<MaterialAppDetail> MaterialAppVouchsLst { get => materialAppVouchsLst; set => materialAppVouchsLst = value; }
}
}

View File

@@ -7,11 +7,8 @@ namespace NX.ERP.U8.Mom
{ {
public class BomDAL public class BomDAL
{ {
public IEnumerable<NX.ERP.Model.Response.MOM.Bom> GetList(string strWhere="", object Params = null) public IEnumerable<NX.ERP.Model.Response.MOM.Bom> GetList(string strWhere="", object Params = null)
{ {
var strSQL = @"select a.BomId,a.Version, a.VersionDesc,a.BomType,c.InvCode as ParentCode ,' ' as id ,d.BomId, d.SortSeq, var strSQL = @"select a.BomId,a.Version, a.VersionDesc,a.BomType,c.InvCode as ParentCode ,' ' as id ,d.BomId, d.SortSeq,
e.InvCode as ComponentCode ,d.BaseQtyN, d.BaseQtyD ,f.WIPType,d.EffBegDate,d.EffEndDate from bom_bom as a e.InvCode as ComponentCode ,d.BaseQtyN, d.BaseQtyD ,f.WIPType,d.EffBegDate,d.EffEndDate from bom_bom as a
left join bom_parent as b on a.BomId=b.BomId left join bom_parent as b on a.BomId=b.BomId
@@ -25,8 +22,6 @@ namespace NX.ERP.U8.Mom
{ {
strSQL += $" where {strWhere} "; strSQL += $" where {strWhere} ";
} }
using (var conn = U8LoginContext.Instance.Connection) using (var conn = U8LoginContext.Instance.Connection)
{ {
var lookup = new Dictionary<int, Model.Response.MOM.Bom>(); var lookup = new Dictionary<int, Model.Response.MOM.Bom>();
@@ -41,24 +36,12 @@ namespace NX.ERP.U8.Mom
{ {
bom = _bom; bom = _bom;
} }
bom.OptionComponents.Add(comp); bom.OptionComponents.Add(comp);
return bom; return bom;
}, Params, null, true, "id", 10, System.Data.CommandType.Text); ; }, Params, null, true, "id", 10, System.Data.CommandType.Text); ;
return lookup.Values; return lookup.Values;
} }
} }

View File

@@ -27,9 +27,7 @@ namespace NX.ERP.U8.Mom
left join mom_orderdetail as b on a.MoId=b.MoId left join mom_orderdetail as b on a.MoId=b.MoId
left join mom_morder as d on b.MoDId=d.MoDId left join mom_morder as d on b.MoDId=d.MoDId
left join mom_SNDetail as e on b.MoDId=e.iVouchsID left join mom_SNDetail as e on b.MoDId=e.iVouchsID
left join mom_moallocate as c on b.MoDId=c.MoDId ";
left join mom_moallocate as c on b.MoDId=c.MoDId
";
if (!string.IsNullOrEmpty(strWhere)) if (!string.IsNullOrEmpty(strWhere))
{ {
strSQL += $" where {strWhere} "; strSQL += $" where {strWhere} ";
@@ -59,9 +57,6 @@ namespace NX.ERP.U8.Mom
OrderDetail = momDetail; OrderDetail = momDetail;
} }
OrderDetail.SN.Add(SN); OrderDetail.SN.Add(SN);
Order.Allocates.Add(MoAllocate); Order.Allocates.Add(MoAllocate);
OrderDetail.ProductAllocateOrderLst.Add(MoAllocate); OrderDetail.ProductAllocateOrderLst.Add(MoAllocate);
MoAllocate.momDetail = OrderDetail; MoAllocate.momDetail = OrderDetail;

View File

@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Dapper;
namespace NX.ERP.U8.Store namespace NX.ERP.U8.Store
{ {
public class MaterialAppVoucher : VoucherBase public class MaterialAppVoucher : VoucherBase
@@ -30,5 +30,56 @@ namespace NX.ERP.U8.Store
} }
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,
b.ID as MaterialAppDtlId,b.cInvCode as MaterialCode,b.fOutQuantity as Qty, b.imoseq as Pesodid from MaterialAppVouch a
left join
MaterialAppVouchs b on a.id=b.ID
";
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>
///
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
public Model.Response.Store.MaterialApp GetModel(string Code)
{
return this.GetList(" a.cCode=@Code", new { Code }).FirstOrDefault();
}
} }
} }

View File

@@ -20,6 +20,152 @@ namespace NX.ERP.U8.Store
} }
private void ByMaterialApp(Model.Request.MaterialStoreOut storeOut, IXMLDOMElement headXml, DOMDocument domBody)
{
var metailApp = new U8.Store.MaterialAppVoucher().GetModel(storeOut.SourceCode);
if (metailApp == null)
{
throw new Exception("未知的领料申请单");
}
headXml.setAttribute("cbustype", "领料");
string lastProductNo = null;
headXml.setAttribute("crdname", "材料出库");
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
bodyXml = domBody.createElement("z:row");
bodyXml.setAttribute("inquantity", "");
bodyXml.setAttribute("innum", "");
bodyXml.setAttribute("imaids","");
bodyXml.setAttribute("imoseq","");
bodyXml.setAttribute("crejectcode", "");
bodyXml.setAttribute("iOMoMID", "");
bodyXml.setAttribute("iopseq", "");
bodyXml.setAttribute("copdesc", "");
bodyXml.setAttribute("invcode", "");
bodyXml.setAttribute("cMoLotCode", "");
bodyXml.setAttribute("cmocode", "");
bodyXml.setAttribute("iMPoIds", "");
bodyXml.setAttribute("comcode", "");
bodyXml.setAttribute("iOMoDID", "");
bodyXml.setAttribute("cciqbookcode", "");
bodyXml.setAttribute("cmworkcentercode", "");
bodyXml.setAttribute("cservicecode", "");
bodyXml.setAttribute("isotype", "");
bodyXml.setAttribute("csocode", "");
bodyXml.setAttribute("isodid", "");
bodyXml.setAttribute("isoseq", "");
bodyXml.setAttribute("iordertype", "");
bodyXml.setAttribute("iordercode", "");
bodyXml.setAttribute("iorderdid", "");
bodyXml.setAttribute("iorderseq", "");
bodyXml.setAttribute("ipesotype", "");
bodyXml.setAttribute("cpesocode", "");
bodyXml.setAttribute("ipesodid", "");
bodyXml.setAttribute("ipesoseq", "");
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
}
headXml.setAttribute("cpspcode", lastProductNo);
}
/// <summary>
/// 生产订单出库
/// </summary>
/// <param name="storeOut"></param>
/// <param name="headXml"></param>
/// <param name="domBody"></param>
private void ByMomOrder(Model.Request.MaterialStoreOut storeOut, IXMLDOMElement headXml, DOMDocument domBody)
{
headXml.setAttribute("cbustype", "领料");
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode);
if (Order == null)
{
throw new Exception($"未知订单:{storeOut.SourceCode}");
}
headXml.setAttribute("iproorderid", Order.ProductOrderId);
headXml.setAttribute("cmpocode", Order.ProductOrderNo);
string lastProductNo = null;
headXml.setAttribute("crdname", "材料出库");
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
var detail = storeOut.Details[n];
var alllocate = Order.Allocates.FirstOrDefault(m => { return m.AllocateId == detail.SorceDetailId; });
if (alllocate == null)
{
throw new Exception($"未知订单明细行:{detail.SorceDetailId}");
}
if (alllocate.MaterialCode != detail.InvCode)
{
throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}");
}
var moomDetail = Order.ProductDtlLst.FirstOrDefault(m => { return m.ProductOrderDtlId == alllocate.ProductOrderDtlId; });
if (lastProductNo == null)
{
lastProductNo = moomDetail.ProductCode;
}
else if (lastProductNo != "" && lastProductNo != moomDetail.ProductCode)
{
lastProductNo = "";
}
headXml.setAttribute("cdepcode", alllocate.momDetail.MDeptCode);
#region 明细
bodyXml = domBody.createElement("z:row");
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
bodyXml.setAttribute("iunitcost", _cost);
var info = new Account.Accinformation();
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
bodyXml.setAttribute("cinvcode", detail.InvCode);
bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", n + 1);
bodyXml.setAttribute("cbatch", "");
bodyXml.setAttribute("cvmivencode", "");
bodyXml.setAttribute("cposition", detail.Position);
bodyXml.setAttribute("editprop", "A");
bodyXml.setAttribute("innum", 10);
bodyXml.setAttribute("autoid", storeOut.Id);
bodyXml.setAttribute("id", storeOut.Id);
bodyXml.setAttribute("impoids", detail.SorceDetailId);
bodyXml.setAttribute("cmocode", Order.ProductOrderNo);
bodyXml.setAttribute("invcode", moomDetail.ProductCode);//产品编码
bodyXml.setAttribute("cwhcode", storeOut.Whcode);
bodyXml.setAttribute("imoseq", 1);
bodyXml.setAttribute("ipesotype", "7");
bodyXml.setAttribute("cpesocode", "");
bodyXml.setAttribute("ipesodid", "");
bodyXml.setAttribute("ipesoseq", "");
bodyXml.setAttribute("isotype", "");
bodyXml.setAttribute("csocode", "");
bodyXml.setAttribute("isodid", "");
bodyXml.setAttribute("isoseq", "");
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
#endregion
}
headXml.setAttribute("cpspcode", lastProductNo);
}
public string AddVocher(Model.Request.MaterialStoreOut storeOut) public string AddVocher(Model.Request.MaterialStoreOut storeOut)
{ {
@@ -45,112 +191,24 @@ namespace NX.ERP.U8.Store
headXml.setAttribute("cvouchtype", this.VoucherID); headXml.setAttribute("cvouchtype", this.VoucherID);
headXml.setAttribute("vt_id", new VT().GetDefaltVTID("0412")); headXml.setAttribute("vt_id", new VT().GetDefaltVTID("0412"));
headXml.setAttribute("editprop", "A"); headXml.setAttribute("editprop", "A");
//headXml.setAttribute("cdepcode", "1");
headXml.setAttribute("crdcode", "201"); headXml.setAttribute("crdcode", "201");
headXml.setAttribute("cwhcode", storeOut.Whcode); headXml.setAttribute("cwhcode", storeOut.Whcode);
headXml.setAttribute("csource", storeOut.Source); headXml.setAttribute("csource", storeOut.Source);
if (storeOut.Source == "生产订单") if (storeOut.Source == "生产订单")
{ {
headXml.setAttribute("cbustype", "领料"); ByMomOrder(storeOut, headXml, domBody);
var Order = new Mom.MomOrderDAL().GetModel(storeOut.SourceCode); }
if (Order == null) else if (storeOut.Source == "领料申请")
{ {
throw new Exception($"未知订单:{storeOut.SourceCode}");
}
headXml.setAttribute("iproorderid", Order.ProductOrderId);
headXml.setAttribute("cmpocode", Order.ProductOrderNo);
string lastProductNo = null;
headXml.setAttribute("crdname", "材料出库");
//headXml.setAttribute("cdepcode", "24");
//headXml.setAttribute("cdepname", "研发LA组"); ByMaterialApp(storeOut, headXml, domBody);
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
var detail = storeOut.Details[n];
var alllocate = Order.Allocates.FirstOrDefault(m => { return m.AllocateId == detail.SorceDetailId; });
if (alllocate == null)
{
throw new Exception($"未知订单明细行:{detail.SorceDetailId}");
} }
if (alllocate.MaterialCode != detail.InvCode)
{
throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}");
}
var moomDetail = Order.ProductDtlLst.FirstOrDefault(m => { return m.ProductOrderDtlId == alllocate.ProductOrderDtlId; });
if (lastProductNo == null)
{
lastProductNo = moomDetail.ProductCode;
}
else if (lastProductNo != "" && lastProductNo != moomDetail.ProductCode)
{
lastProductNo = "";
}
headXml.setAttribute("cdepcode", alllocate.momDetail.MDeptCode);
#region 明细
bodyXml = domBody.createElement("z:row");
var metail = new NX.ERP.U8.MaterialDAL().GetInvPrice(detail.InvCode, 1, storeOut.Whcode, out var _cost);
bodyXml.setAttribute("iunitcost", _cost);
var info = new Account.Accinformation();
bodyXml.setAttribute("iprice", info.FormatMoney(_cost * detail.Quantity));
//bodyXml.setAttribute("autoid", n);
bodyXml.setAttribute("cinvcode", detail.InvCode);
bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", n + 1);
bodyXml.setAttribute("cbatch", "");
bodyXml.setAttribute("cvmivencode", "");
bodyXml.setAttribute("cposition", detail.Position);
bodyXml.setAttribute("editprop", "A");
bodyXml.setAttribute("innum", 10);
bodyXml.setAttribute("autoid", storeOut.Id);
bodyXml.setAttribute("id", storeOut.Id);
bodyXml.setAttribute("impoids", detail.SorceDetailId);
bodyXml.setAttribute("cmocode", Order.ProductOrderNo);
bodyXml.setAttribute("invcode", moomDetail.ProductCode);//产品编码
bodyXml.setAttribute("cwhcode", storeOut.Whcode);
bodyXml.setAttribute("imoseq", 1);
bodyXml.setAttribute("ipesotype", "7");
bodyXml.setAttribute("cpesocode", "");
bodyXml.setAttribute("ipesodid", "");
bodyXml.setAttribute("ipesoseq", "");
bodyXml.setAttribute("isotype", "");
bodyXml.setAttribute("csocode", "");
bodyXml.setAttribute("isodid", "");
bodyXml.setAttribute("isoseq", "");
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
#endregion
}
headXml.setAttribute("cpspcode", lastProductNo);
}
domHead.selectSingleNode("//rs:data").appendChild(headXml); domHead.selectSingleNode("//rs:data").appendChild(headXml);
try try

View File

@@ -8,13 +8,13 @@ namespace NX.ERP.WebAPi.Controllers.Store
{ {
public class MaterialAppVoucherController : ApiController public class MaterialAppVoucherController : ApiController
{ {
[Route("api/MaterialAppVoucher/Add")] [Route("api/MaterialAppVoucher/List")]
[HttpPost] [HttpPost]
public string Add() public IEnumerable<Model.Response.Store.MaterialApp> Lsit()
{ {
var dal = new NX.ERP.U8.Store.MaterialAppVoucher(); var dal = new NX.ERP.U8.Store.MaterialAppVoucher();
return dal.AddVoucher(new { }); return dal.GetList();
} }
} }
} }

View File

@@ -5,7 +5,7 @@
--> -->
<configuration> <configuration>
<appSettings> <appSettings>
<add key="server" value="192.168.1.14" /> <add key="server" value="172.30.6.150" />
<add key="AccId" value="002" /> <add key="AccId" value="002" />
<add key="UserId" value="0001" /> <add key="UserId" value="0001" />
<add key="Password" value="123456" /> <add key="Password" value="123456" />