176 lines
7.8 KiB
C#
176 lines
7.8 KiB
C#
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
|
|
}
|
|
} |