物资管理API

This commit is contained in:
2025-05-26 15:30:17 +08:00
parent 3c8d570fc1
commit c8497c1dbf
14 changed files with 488 additions and 120 deletions
@@ -0,0 +1,176 @@
using Aspose.Words;
using BLL;
using Microsoft.Office.Interop.Excel;
using Model;
using System.Data;
using System.Linq;
using System.Web.Http;
namespace WebAPI.Controllers
{
/*
* 物资管理的一些基础信息
* **/
public class MaterialsBasicsController : ApiController
{
#region
public Model.ResponeData GetUnitList(string projectId, string keyWord = "" )
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
if (string.IsNullOrEmpty(keyWord))
{
keyWord = ""; // 明确使用默认值
}
var list = Funs.DB.Cl_b_unitapp.Where(x => x.ProjectId == projectId && x.UAName.Contains(keyWord)).ToList();
responeData.data = list;
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
public Model.ResponeData getInstallationList(string projectId, string keyWord = "")
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
if (string.IsNullOrEmpty(keyWord))
{
keyWord = ""; // 明确使用默认值
}
responeData.data = Funs.DB.Cl_b_Installation.Where(x => x.ProjectId == projectId&&x.InstallationName.Contains(keyWord))
.Select(x => new {
x.InstallationId,
x.InstallationCode,
x.InstallationName,
}).ToList();
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
public Model.ResponeData getSpecialityList(string projectId, string keyWord = "")
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
if (string.IsNullOrEmpty(keyWord))
{
keyWord = ""; // 明确使用默认值
}
responeData.data = Funs.DB.CL_B_Speciality.Where(x => x.ProjectId == projectId && x.SpecialityName.Contains(keyWord))
.Select(x => new {
x.Specialityid,
x.SpecialityCode,
x.SpecialityName
}).ToList();
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
public Model.ResponeData GetMaterialsBySystemCode(string ProjectId, string code)
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
responeData.data = (
from cl in Funs.DB.Cl_w_comp
join bm in Funs.DB.CL_B_Material on cl.MaterialID equals bm.MaterialID
join bi in Funs.DB.Cl_b_Installation on cl.InstallationId equals bi.InstallationId
where cl.ProjectId == ProjectId
select new
{
ProjectId = cl.ProjectId, // 项目ID
InstallationId = cl.InstallationId, // 专业ID
Installationname = bi.InstallationName, // 专业名称
ghfs = cl.Ghfs, // 采购方类别
MaterialID = bm.MaterialID, // 物资ID
MaterialName = bm.MaterialName, // 物资名称
Specificationtype = bm.Specificationtype, // 规格
TechnicalConditions = bm.TechnicalConditions,
StandardSpecification = bm.StandardSpecification,
MaterialQuality = bm.MaterialQuality,
Unit = bm.Unit, // 单位
SystemCode = bm.SystemCode, // 编号
AreaCode = cl.TAreaMaterialMID, // 工区
jh_quantity = cl.Pquantity, // 计划量
ck_quantity = cl.Pquantity - cl.OQuantity, // 最大允许出库量
kc_quantity = cl.SQuantity - cl.OQuantity + cl.RQuantity - cl.HQuantity // 库存量
}
).FirstOrDefault(x=>x.SystemCode == code);
}
catch ( System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
public Model.ResponeData GetMaterialsList(string ProjectId, string InstallationId, string ghfs, string area)
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
var list = (
from cl in Funs.DB.Cl_w_comp
join bm in Funs.DB.CL_B_Material on cl.MaterialID equals bm.MaterialID
join bi in Funs.DB.Cl_b_Installation on cl.InstallationId equals bi.InstallationId
where cl.ProjectId == ProjectId && cl.InstallationId == InstallationId && cl.Ghfs == ghfs && cl.TAreaMaterialMID == area
select new
{
ProjectId = cl.ProjectId, // 项目ID
InstallationId = cl.InstallationId, // 专业ID
Installationname = bi.InstallationName, // 专业名称
ghfs = cl.Ghfs, // 采购方类别
MaterialID = bm.MaterialID, // 物资ID
MaterialName = bm.MaterialName, // 物资名称
Specificationtype = bm.Specificationtype, // 规格
TechnicalConditions = bm.TechnicalConditions,
StandardSpecification = bm.StandardSpecification,
MaterialQuality = bm.MaterialQuality,
Unit = bm.Unit, // 单位
SystemCode = bm.SystemCode, // 编号
AreaCode = cl.TAreaMaterialMID, // 工区
jh_quantity = cl.Pquantity, // 计划量
ck_quantity = cl.Pquantity - cl.OQuantity, // 最大允许出库量
kc_quantity = cl.SQuantity - cl.OQuantity + cl.RQuantity - cl.HQuantity // 库存量
}
).ToList();
responeData.data = list;
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}
@@ -0,0 +1,104 @@
using BLL;
using System;
using System.Linq;
using System.Web.Http;
namespace WebAPI.Controllers
{
/**
* 物资出库
*/
public class MaterialsOutController : ApiController
{
#region
[HttpPost]
public Model.ResponeData AddMaterialOutM(Model.Cl_W_MaterialOutM MaterialOutM)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
int count = db.Cl_W_MaterialOutM.Where(x => x.UserTime == DateTime.Now).ToList().Count();
Model.Cl_W_MaterialOutM outm = new Model.Cl_W_MaterialOutM();
outm.OutSheetMID = MaterialOutM.OutSheetMID;
outm.ProjectId = MaterialOutM.ProjectId;
outm.OutSheetCode = string.Format("CKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"),count.ToString("000"));
outm.UserTime = DateTime.Now;
outm.UnitId = MaterialOutM.UnitId;
outm.UAid = MaterialOutM.UAid;
outm.InstallationId = MaterialOutM.InstallationId;
outm.PlanSheetMID = MaterialOutM.PlanSheetMID; // 工区ID
outm.YYPID = MaterialOutM.YYPID;
outm.RecordMan = MaterialOutM.RecordMan;
db.Cl_W_MaterialOutM.InsertOnSubmit(outm);
db.SubmitChanges();
responeData.data = MaterialOutM.OutSheetMID;
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
[HttpPost]
public Model.ResponeData AddMaterialOutS(Model.Cl_W_MaterialOutS MaterialOutS)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
int count = db.Cl_W_MaterialOutM.Where(x => x.UserTime == DateTime.Now).ToList().Count();
Model.Cl_W_MaterialOutS outs = new Model.Cl_W_MaterialOutS();
outs.ProjectId = MaterialOutS.ProjectId;
outs.OutSheetMID = MaterialOutS.OutSheetMID;
outs.OutSheetSID = Guid.NewGuid().ToString();
outs.MaterialID = MaterialOutS.MaterialID;
//outs.Soft = MaterialOutS.Soft ?? DBNull.Value;
outs.PlannedQuantity = MaterialOutS.PlannedQuantity;
outs.StoreQuantity = MaterialOutS.StoreQuantity;
outs.OutQuantity = MaterialOutS.OutQuantity;
outs.OutQuantityY = MaterialOutS.OutQuantityY;
outs.StorePQuantity = MaterialOutS.StorePQuantity;
outs.CertificatesFactoryNo = MaterialOutS.CertificatesFactoryNo;
outs.FurnaceBatchNo = MaterialOutS.FurnaceBatchNo;
outs.CertificateSelfNo = MaterialOutS.CertificateSelfNo;
outs.Weight = MaterialOutS.Weight;
outs.Price = MaterialOutS.Price;
outs.OutQuantityP = MaterialOutS.OutQuantityP;
outs.OutQuantityO = MaterialOutS.OutQuantityO;
outs.StorehouseName = MaterialOutS.StorehouseName;
outs.StorageSheetSID = MaterialOutS.StorageSheetSID;
outs.FirstpartyCode = MaterialOutS.FirstpartyCode;
outs.ISupload = MaterialOutS.ISupload;
outs.InstallationId = MaterialOutS.InstallationId;
outs.Shue = MaterialOutS.Shue;
outs.Bhsje = MaterialOutS.Bhsje;
db.Cl_W_MaterialOutS.InsertOnSubmit(outs);
db.SubmitChanges();
responeData.data = MaterialOutS.OutSheetSID;
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}