导入走API

This commit is contained in:
gongxh
2021-06-01 15:12:33 +08:00
parent a769186462
commit cf102ad57f
5 changed files with 99 additions and 73 deletions

View File

@@ -34,7 +34,11 @@ namespace NX.ERP.Model.Request
public IEnumerable<MaterialAppDetail> MaterialAppDetails = new List<MaterialAppDetail>(); public IEnumerable<MaterialAppDetail> MaterialAppDetails = new List<MaterialAppDetail>();
public string PersonCode { get; set; }
public string Maker { get; set; }
public string DepCode { get; set; }
} }
} }

View File

@@ -175,7 +175,7 @@ namespace U8AppMain
// //
this.领料单ToolStripMenuItem.Name = "领料单ToolStripMenuItem"; this.领料单ToolStripMenuItem.Name = "领料单ToolStripMenuItem";
this.领料单ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.领料单ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.领料单ToolStripMenuItem.Text = "领料单"; this.领料单ToolStripMenuItem.Text = "领料申请单";
this.领料单ToolStripMenuItem.Click += new System.EventHandler(this.领料单ToolStripMenuItem_Click); this.领料单ToolStripMenuItem.Click += new System.EventHandler(this.领料单ToolStripMenuItem_Click);
// //
// 打印ToolStripMenuItem // 打印ToolStripMenuItem

View File

@@ -280,7 +280,7 @@ namespace U8AppMain
foreach (var item in bomLookup.Values) foreach (var item in bomLookup.Values)
{ {
var a = new Voucher.VoucherDAL(U8LoginContext.Instance.Constr4Net); var a = new Voucher.VoucherDAL(U8LoginContext.Instance.Constr4Net);
if (a.Add(item)) if (a.Add(item)!="")
{ {
this.richTextBox1.SelectionColor = Color.Green; this.richTextBox1.SelectionColor = Color.Green;
this.richTextBox1.AppendText($" {item.cDefine12} 导入成功 ,实际U8单号: {item.CCode} \r\n"); this.richTextBox1.AppendText($" {item.cDefine12} 导入成功 ,实际U8单号: {item.CCode} \r\n");

View File

@@ -34,78 +34,103 @@ namespace U8AppMain.Voucher
_connStr = connStr; _connStr = connStr;
} }
public bool Add(Vouch vouch) public string Add(Vouch vouch)
{ {
var dal = new NX.ERP.U8.Store.MaterialAppDAL();
string accid = NX.ERP.U8.U8LoginContext.Instance.AccID; return dal.AddVoucher(new NX.ERP.Model.Request.MaterialApp()
var conn = new SqlConnection(this._connStr);
conn.Open();
var trans = conn.BeginTransaction();
try
{ {
//获取ID
var idEnity = new IdEnity Date = vouch.DDate,
source = "",
SourceCode = "",
DepCode=vouch.CDepCode,
PersonCode=vouch.CPersonCode,
Maker=vouch.CMaker,
MaterialAppDetails = vouch.Vouchs.ToList().ConvertAll(m =>
{ {
cAcc_Id = accid, return new NX.ERP.Model.Request.MaterialAppDetail()
cVouchType = "mv", {
iAmount = vouch.Vouchs.Count()
};
DynamicParameters sp = new DynamicParameters(idEnity);
sp.Add("@iFatherId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
sp.Add("@iChildId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
conn.Execute("sp_GetID", sp, trans, commandType: System.Data.CommandType.StoredProcedure);
int iFatherId = sp.Get<int>("@iFatherId");
int iChildId = sp.Get<int>("@iChildId");
//获取最大值
var cSeed = DateTime.Today.ToString("yyyyMM");
var sqlMax = $@"select cNumber as Maxnumber From VoucherHistory with (ROWLOCK) Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed";
var maxCode = conn.ExecuteScalar<int>(sqlMax, new { cSeed }, trans,200,System.Data.CommandType.Text);
maxCode++;
//更新最大之
var sqlUpdate = "update VoucherHistory set cNumber=@cNumber Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed ";
conn.Execute(sqlUpdate, new { cNumber = maxCode, cSeed }, trans);
//获取前缀 Duedate = DateTime.Now,
var sqlPrefix = " Select Prefix1Rule From VoucherNumber Where CardNumber = '0413'"; MaterialCode = m.CInvCode,
var prefix = conn.ExecuteScalar<string>(sqlPrefix, null, trans,200,System.Data.CommandType.Text); Qty = m.Iquantity
//组装Code
var cCode = prefix + cSeed.Substring(2, cSeed.Length - 2) + maxCode.ToString().PadLeft(5, '0');
//主表
var sql = @"insert into MaterialAppVouch(id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,dnmaketime,cDefine12)
values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate(),@cDefine12)";
vouch.ID = iFatherId;
vouch.cDefine12 = vouch.CCode;
vouch.CCode = cCode;
conn.Execute(sql, vouch, trans);
sql = @"INSERT INTO MaterialAppVouchs (autoid, id, cinvcode, inum, iquantity , cwhcode, iexpiratdatecalcu, irowno, iordertype, isotype , ipesotype)
VALUES (@autoid, @id, @cinvcode, @inum, @iquantity , @cwhcode, @iexpiratdatecalcu, @irowno, @iordertype, @isotype , @ipesotype)";
//明细
var n = vouch.Vouchs.Count() - 1;
foreach (var item in vouch.Vouchs)
{
item.autoid = iChildId - n;
item.id = iFatherId;
n--;
item.IRowNO = n;
}
conn.Execute(sql, vouch.Vouchs, trans);
trans.Commit();
}
catch (Exception err)
{
trans.Rollback(); };
throw err;
} })
finally
{
conn.Close();
} });
return true;
//string accid = NX.ERP.U8.U8LoginContext.Instance.AccID;
//var conn = new SqlConnection(this._connStr);
//conn.Open();
//var trans = conn.BeginTransaction();
//try
//{
// //获取ID
// var idEnity = new IdEnity
// {
// cAcc_Id = accid,
// cVouchType = "mv",
// iAmount = vouch.Vouchs.Count()
// };
// DynamicParameters sp = new DynamicParameters(idEnity);
// sp.Add("@iFatherId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
// sp.Add("@iChildId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
// conn.Execute("sp_GetID", sp, trans, commandType: System.Data.CommandType.StoredProcedure);
// int iFatherId = sp.Get<int>("@iFatherId");
// int iChildId = sp.Get<int>("@iChildId");
// //获取最大值
// var cSeed = DateTime.Today.ToString("yyyyMM");
// var sqlMax = $@"select cNumber as Maxnumber From VoucherHistory with (ROWLOCK) Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed";
// var maxCode = conn.ExecuteScalar<int>(sqlMax, new { cSeed }, trans,200,System.Data.CommandType.Text);
// maxCode++;
// //更新最大之
// var sqlUpdate = "update VoucherHistory set cNumber=@cNumber Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed ";
// conn.Execute(sqlUpdate, new { cNumber = maxCode, cSeed }, trans);
// //获取前缀
// var sqlPrefix = " Select Prefix1Rule From VoucherNumber Where CardNumber = '0413'";
// var prefix = conn.ExecuteScalar<string>(sqlPrefix, null, trans,200,System.Data.CommandType.Text);
// //组装Code
// var cCode = prefix + cSeed.Substring(2, cSeed.Length - 2) + maxCode.ToString().PadLeft(5, '0');
// //主表
// var sql = @"insert into MaterialAppVouch(id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,dnmaketime,cDefine12)
// values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate(),@cDefine12)";
// vouch.ID = iFatherId;
// vouch.cDefine12 = vouch.CCode;
// vouch.CCode = cCode;
// conn.Execute(sql, vouch, trans);
// sql = @"INSERT INTO MaterialAppVouchs (autoid, id, cinvcode, inum, iquantity , cwhcode, iexpiratdatecalcu, irowno, iordertype, isotype , ipesotype)
// VALUES (@autoid, @id, @cinvcode, @inum, @iquantity , @cwhcode, @iexpiratdatecalcu, @irowno, @iordertype, @isotype , @ipesotype)";
// //明细
// var n = vouch.Vouchs.Count() - 1;
// foreach (var item in vouch.Vouchs)
// {
// item.autoid = iChildId - n;
// item.id = iFatherId;
// n--;
// item.IRowNO = n;
// }
// conn.Execute(sql, vouch.Vouchs, trans);
// trans.Commit();
// }
// catch (Exception err)
// {
// trans.Rollback();
// throw err;
// }
// finally
// {
// conn.Close();
// }
//return true;

View File

@@ -42,7 +42,9 @@ namespace NX.ERP.U8.Store
headXml.setAttribute("vt_id", "30718"); headXml.setAttribute("vt_id", "30718");
headXml.setAttribute("csource", param.source); headXml.setAttribute("csource", param.source);
headXml.setAttribute("cRdCode", "206"); headXml.setAttribute("cRdCode", "206");
headXml.setAttribute("cDepCode", "5401"); headXml.setAttribute("cDepCode", param.DepCode);
headXml.setAttribute("cMaker", param.Maker);
headXml.setAttribute("cPersonCode", param.PersonCode);
Model.MOM.MomOrder Order = null; Model.MOM.MomOrder Order = null;
if (param.source == "生产订单") if (param.source == "生产订单")
{ {
@@ -73,8 +75,6 @@ namespace NX.ERP.U8.Store
bodyXml.setAttribute("ipesotype", 7); bodyXml.setAttribute("ipesotype", 7);
bodyXml.setAttribute("cpesocode", param.SourceCode); bodyXml.setAttribute("cpesocode", param.SourceCode);
bodyXml.setAttribute("ipesoseq", detail.momDetail.SortSeq); bodyXml.setAttribute("ipesoseq", detail.momDetail.SortSeq);
} }
domBody.selectSingleNode("//rs:data").appendChild(bodyXml); domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
} }
@@ -155,9 +155,6 @@ FROM MaterialAppVouch a
public IEnumerable<Model.Response.Store.MaterialApp> GetPendingList() public IEnumerable<Model.Response.Store.MaterialApp> GetPendingList()
{ {
return this.GetList(" b.cDefine22='是' and iQuantity<>ISNULL( fOutQuantity,0)"); return this.GetList(" b.cDefine22='是' and iQuantity<>ISNULL( fOutQuantity,0)");
} }