添加导出到货单接口

This commit is contained in:
admin
2021-01-05 16:49:51 +08:00
parent e9b4b307c9
commit 3ab387f51a
20 changed files with 339 additions and 74 deletions

View File

@@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model
{
/// <summary>
/// 到货单
/// </summary>
public class Arrival
{
private int id;
private string arrivalCode;
private DateTime _date;
}
}

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Model
{
public class ArrivalDetail
{
public int Autoid;
}
}

View File

@@ -57,16 +57,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Arrival.cs" />
<Compile Include="Model\ArrivalDetail.cs" />
<Compile Include="Model\Bin.cs" />
<Compile Include="Model\Customer.cs" />
<Compile Include="Model\Materiel.cs" />
<Compile Include="Model\MaterielType.cs" />
<Compile Include="Model\Supplier.cs" />
<Compile Include="Model\Unit.cs" />
<Compile Include="Model\Warehouse.cs" />
<Compile Include="Purchase\Arrival.cs" />
<Compile Include="Purchase\ArrivalDetail.cs" />
<Compile Include="Base\Bin.cs" />
<Compile Include="Base\Customer.cs" />
<Compile Include="Base\Materiel.cs" />
<Compile Include="Base\MaterielType.cs" />
<Compile Include="Base\Supplier.cs" />
<Compile Include="Base\Unit.cs" />
<Compile Include="Base\Warehouse.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Store\PuStoreIn.cs" />
<Compile Include="Store\PuStoreInDetail.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Purchase
{
/// <summary>
/// 到货单
/// </summary>
public class Arrival
{
private int id;
private string arrivalCode;
private DateTime _date;
private string supplierCode;
private ICollection<ArrivalDetail> arrivalDetails = new List<ArrivalDetail>();
public int Id { get => id; set => id = value; }
public string ArrivalCode { get => arrivalCode; set => arrivalCode = value; }
public DateTime Date { get => _date; set => _date = value; }
public ICollection<ArrivalDetail> ArrivalDetails { get => arrivalDetails; set => arrivalDetails = value; }
public string SupplierCode { get => supplierCode; set => supplierCode = value; }
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Purchase
{
/// <summary>
/// 到货明细
/// </summary>
public class ArrivalDetail
{
private int id;
private string materielCode;
public int Id { get => id; set => id = value; }
public int ArrivalID { get => arrivalID; set => arrivalID = value; }
public string MaterielCode { get => materielCode; set => materielCode = value; }
public string BatchNo { get => batchNo; set => batchNo = value; }
public string UnitCode { get => unitCode; set => unitCode = value; }
public decimal Quantity { get => quantity; set => quantity = value; }
/// <summary>
/// 审批状态2 说明已经审核过了
/// </summary>
public int Iverifystateex { get => iverifystateex; set => iverifystateex = value; }
private int arrivalID;
private string batchNo;
private string unitCode;
private decimal quantity;
private int iverifystateex;
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Store
{
public class PuStoreIn
{
private int id;
private string code;
private DateTime date;
private string depcode;
private string whcode;
private ICollection<PuStoreInDetail> puStoreInDetails = new List<PuStoreInDetail>();
public ICollection<PuStoreInDetail> PuStoreInDetails { get => puStoreInDetails; set => puStoreInDetails = value; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Store
{
public class PuStoreInDetail
{
private int id;
private int puStoreInId;
private string invcode;
private string unit;
private string quantity;
}
}

138
NX.ERP.U8/AdoHelper.cs Normal file
View File

@@ -0,0 +1,138 @@
using ADODB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.U8
{
public class AdoHelper : IDisposable
{
private ADODB.Connection connection;
public Connection Connection { get => connection; set => connection = value; }
public void BeginTrans()
{
try
{
if (Connection != null)
{
Connection.BeginTrans();
}
}
catch (Exception)
{
throw;
}
}
public AdoHelper(string constr)
{
if (!string.IsNullOrEmpty(constr))
{
connection = new ConnectionClass();
connection.ConnectionString = constr;
try
{
connection.Open();
}
catch (Exception err)
{
throw new Exception(err.Message);
}
}
else
{
throw new Exception("链接字符串为空");
}
}
public Recordset U8ExcuteRecord(string strSQL)
{
try
{
return connection.Execute(strSQL, out object RecordsAffected);
}
catch (Exception)
{
throw;
}
}
public int ExcuteNoneQuery(string strSQL)
{
try
{
Connection.Execute(strSQL, out var RecordsAffected);
return (int)RecordsAffected;
}
catch (Exception)
{
throw;
}
}
public void RollbackTrans()
{
try
{
if (Connection != null)
{
Connection.RollbackTrans();
}
}
catch (Exception)
{
throw;
}
}
public void CommitTrans()
{
try
{
if (Connection != null)
{
Connection.CommitTrans();
}
}
catch (Exception)
{
throw;
}
}
public void Dispose()
{
try
{
if (Connection != null)
{
if (Connection.State == 1)
{
Connection.Close();
}
Connection = null;
}
}
catch (Exception)
{
throw;
}
}
}
}

View File

@@ -36,10 +36,12 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="AdoHelper.cs" />
<Compile Include="Base\BinDAL.cs" />
<Compile Include="Base\CustomerDAL.cs" />
<Compile Include="Base\MaterielDAL.cs" />
<Compile Include="Base\MaterielTypeDAL.cs" />
<Compile Include="Purchase\ArrivalDAL.cs" />
<Compile Include="STVocher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Base\SupplierDAL.cs" />

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
namespace NX.ERP.U8.Purchase
{
public class ArrivalDAL
{
public IEnumerable<Model.Purchase.Arrival> GetList()
{
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
{
string strSQL = @"select a.id,a.cCode as ArrivalCode,a.dDate as date,A.cVenCode AS SupplierCode,
B.Autoid as id,b.ID as ArrivalID,
b.cInvCode AS MaterielCode,
b.cBatch AS BatchNo,
b.cUnitID AS UnitCode,
B.iQuantity as Quantity
from PU_ArrivalVouch as a
left join PU_ArrivalVouchs as b on a.id=b.id";
var lookup = new Dictionary<int, Model.Purchase.Arrival>();
// return conn.Query<Model.Purchase.Arrival>(strSQL,null);
var list = conn.Query<Model.Purchase.Arrival, Model.Purchase.ArrivalDetail, Model.Purchase.Arrival>(strSQL, (arrival, ArrivalDetail) =>
{
if (!lookup.TryGetValue(arrival.Id, out var _arrival))
{
lookup.Add(arrival.Id, arrival);
} else
{
arrival = _arrival;
}
arrival.ArrivalDetails.Add(ArrivalDetail);
return arrival;
}, null, null, true, "id", 10, System.Data.CommandType.Text);
return lookup.Values;
}
}
}
}

View File

@@ -8,15 +8,11 @@ namespace NX.ERP.U8
{
public class U8LoginContext : IDisposable
{
private static U8LoginContext _u8LoginContext;
public static U8LoginContext Instance
{
get
{
if (_u8LoginContext == null)
{
_u8LoginContext = new U8LoginContext();
@@ -24,17 +20,21 @@ namespace NX.ERP.U8
return _u8LoginContext;
}
}
private UFSoft.U8.Framework.Login.UI.clsLogin uiLogin;
private clsLogin _clslogin;
public string cAcc_id
{
get
{
return this._clslogin.get_cAcc_Id();
}
}
public U8LoginContext()
{
//uiLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();
}
public clsLogin ClsLogin
{
get
@@ -55,7 +55,6 @@ namespace NX.ERP.U8
uiLogin.ShutDown();
uiLogin = null;
}
}
public string UserId { get; set; } = "003";
@@ -63,14 +62,12 @@ namespace NX.ERP.U8
public string Server { get; set; } = "192.168.0.250";
public string AccID { get; set; } = "u8@889";
public string AccID { get; set; } = "(default)@001";
public string Serial { get; set; }
/// <summary>
/// ADO.NET 链接字符串
/// </summary>
public string Constr4Net
{
get
@@ -78,10 +75,10 @@ namespace NX.ERP.U8
return this.ClsLogin.UFDataConnstringForNet;
}
}
/// <summary>
/// ADO的链接字符串
/// </summary>
public string Constr
{
get
{
@@ -102,18 +99,24 @@ namespace NX.ERP.U8
}
public void Login(bool showlogin = false)
{
if (!UiLogin.login("DP", "wx998", "", "192.168.0.250", "2020-12-31", AccID, Serial, showlogin))
if (showlogin)
{
throw new Exception(UiLogin.ErrDescript);
if (!UiLogin.login("DP"))
{
throw new Exception(UiLogin.ErrDescript);
}
}
else
{
if (!UiLogin.login("DP", "wx999", "!@#qwe123", "192.168.0.168", DateTime.Today.ToString("yyyy-MM-dd"), AccID, Serial))
{
throw new Exception(UiLogin.ErrDescript);
}
}
if (UiLogin.SubLogin("ST") == null)
{
@@ -126,7 +129,7 @@ namespace NX.ERP.U8
}
_clslogin.set_TaskId(UiLogin.GetTaskID("ST"));
}
}
}

View File

@@ -0,0 +1,22 @@
using NX.ERP.U8.Purchase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
namespace NX.ERP.WebAPi.Controllers
{
public class ArrivalController : ApiController
{
// GET api/values
[HttpGet]
public IEnumerable<Model.Purchase.Arrival> List()
{
var customerDAL = new ArrivalDAL();
return customerDAL.GetList();
}
}
}

View File

@@ -127,6 +127,7 @@
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\ArrivalController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\CustomerController.cs" />
<Compile Include="Controllers\MaterielController.cs" />