1、区域API StorageAreas
库区一般是指仓库下根据不同的功能区分的,如临时入库区,零拣区,大货区,临时出库区,中转区等等。而区域可以理解为地理上面的划分,在库区下再划分区域,主要是用于分工或者分组。比如将大货区分为A/B/C,某人拣货的区域只有A,或者是根据商品将某个供应商的货都放在A区,要看实际的仓库应用场景。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WMS_WebAPI.Models.Context;
namespace WMS_WebAPI.Controllers
{
[Authorize]
[RoutePrefix("api/StorageAreaMaster")]
public class StorageAreaMasterController : ApiController
{
private WMS_Entities _context;
StorageAreaMasterController()
{
_context = new WMS_Entities();
}
[HttpGet]
[Route("")]
public IHttpActionResult GetWarehouse(int WarehouseID)
{
var data = _context.GetStorageArea_byWarehouse(WarehouseID).ToList();
if (data == null)
{
return NotFound();
}
return Ok(data);
}
//--------------
}
}
2、区域API Storage
using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.Http;
using WMS_WebAPI.Models;
using WMS_WebAPI.Models.Context;
namespace WMS_WebAPI.Controllers
{
public class StorageController : ApiController
{
WMS_Entities _context = new WMS_Entities();
CommanListToDataTableConverter ConvertDataTable = new CommanListToDataTableConverter();
string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
[HttpPost]
[Route("api/Storage/StorageAreas_Insert")]
public IHttpActionResult StorageAreas_Insert(cls_Storage obj)
{
DataTable dtLTD_StorageAreaS = new DataTable();
dtLTD_StorageAreaS = ConvertDataTable.ConvertToDataTable(obj.LTD_StorageAreaS);
DataSet ds = new DataSet();
try
{
using (SqlConnection connection = new SqlConnection(connectionstring))
{
using (SqlCommand command = new SqlCommand("StorageAreas_Insert", connection))
{
command.CommandType = System.Data.CommandType.StoredProcedure;
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@StorageAreaID", Convert.ToInt32(obj.StorageAreaID));
param[1] = new SqlParameter("@Storage", dtLTD_StorageAreaS);
param[2] = new SqlParameter("@createdBy", Convert.ToInt32(obj.createdBy));
param[3] = new SqlParameter("@BlockID", Convert.ToInt32(obj.BlockID));
param[1].SqlDbType = SqlDbType.Structured;
command.Parameters.AddRange(param);
connection.Open();
using (SqlDataAdapter da = new SqlDataAdapter(command))
{
da.Fill(ds);
}
connection.Close();
}
return Ok(ds);
}
}
catch (System.Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost]
[Route("api/Storage/StorageArea_Select")]
public IHttpActionResult StorageArea_Select(cls_Storage obj)
{
try
{
var data = _context.StorageArea_Select(obj.warehouseID).ToList();
if (data == null)
{
return NotFound();
}
return Ok(data);
}
catch (System.Exception)
{
return BadRequest();
}
}
}
}