This commit is contained in:
2025-07-10 17:09:23 +08:00
25 changed files with 1309 additions and 1871 deletions
@@ -176,7 +176,17 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
responeData.data = APIHazardRegisterService.getHazardRegisterByProjectIdStates(projectId, checkDate);
if(string.IsNullOrEmpty(projectId))
{
projectId = ""; // 明确使用默认值
responeData.data = APIHazardRegisterService.getHazardRegisterByProjectIdStates(projectId,checkDate);
}
else
{
responeData.data = APIHazardRegisterService.getHazardRegisterByProjectIdStates(projectId, checkDate);
}
}
catch (Exception ex)
{
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,230 @@
using Aspose.Words;
using BLL;
using Microsoft.Office.Interop.Excel;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net.NetworkInformation;
using System.Web.Http;
using static WebAPI.Controllers.HSSE.ImageRecognitionController;
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 InstallationId, string ghfs, string area, string code)
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
string strSql = "SELECT cp.ProjectId,cp.InstallationId,zz.Installationname AS InstallationName,ghfs AS Ghfs,cp.MaterialID,MaterialName,specificationtype AS Specificationtype,MaterialQuality,standardspecification ,unit AS Unit," +
"technicalconditions AS TechnicalConditions,SystemCode,rtrim( ltrim( TAreaMaterialMID ) ) AS AreaCode,0.000 AS bcckl,SUM ( Aquantity ) AS Aquantity,SUM ( Pquantity ) AS jh_quantity,SUM ( SQuantity ) AS dj_quantity,SUM ( HQuantity ) AS hj_quantity,SUM ( Pquantity ) - SUM ( OQuantity ) AS ck_quantity,SUM ( RQuantity ) AS tk_quantity,(SELECT SUM( SQuantity ) - SUM ( OQuantity ) + SUM ( RQuantity ) - SUM ( HQuantity ) FROM cl_w_comp WHERE cl_w_comp.MaterialID= cp.MaterialID AND cl_w_comp.InstallationId= cp.InstallationId AND cl_w_comp.ghfs= cp.ghfs ) AS kc_quantity,ROW_NUMBER ( ) OVER ( ORDER BY zz.InstallationCode,SystemCode ASC ) AS RowNum,0 AS xz,0 AS xh FROM cl_w_comp cp LEFT JOIN CL_B_Material mt ON mt.MaterialID= cp.MaterialID LEFT JOIN cl_b_Installation zz ON zz.InstallationId= cp.InstallationId GROUP BY cp.ProjectId,cp.InstallationId,zz.InstallationCode,zz.Installationname,ghfs,cp.MaterialID,MaterialName,specificationtype,MaterialQuality,standardspecification,unit,technicalconditions,SystemCode,TAreaMaterialMID HAVING ";
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += "cp.ProjectId= @ProjectId AND cp.installationid= @InstallationId AND TAreaMaterialMID = @area AND ghfs = @ghfs AND SystemCode = @code";
listStr.Add(new SqlParameter("@ProjectId", ProjectId));
listStr.Add(new SqlParameter("@InstallationId", InstallationId));
listStr.Add(new SqlParameter("@ghfs", ghfs));
listStr.Add(new SqlParameter("@area", area));
listStr.Add(new SqlParameter("@code", code));
SqlParameter[] parameter = listStr.ToArray();
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
responeData.data = tb;
//responeData.data = (
//from bm in Funs.DB.CL_B_Material
//where bm.SystemCode == code && bm.ProjectId == ProjectId
//select new
//{
// ProjectId = bm.ProjectId, // 项目ID
// InstallationId = Funs.DB.Cl_w_comp.FirstOrDefault(x => x.MaterialID == bm.MaterialID).InstallationId, // 专业ID
// Installationname = Funs.DB.Cl_b_Installation.FirstOrDefault(x => x.InstallationId == Funs.DB.Cl_w_comp.FirstOrDefault(y => y.MaterialID == bm.MaterialID).InstallationId).InstallationName, // 专业名称
// ghfs = Funs.DB.Cl_w_comp.FirstOrDefault(x => x.MaterialID == bm.MaterialID).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 = Funs.DB.Cl_w_comp.FirstOrDefault(x => x.MaterialID == bm.MaterialID).TAreaMaterialMID, // 工区
// jh_quantity = Funs.DB.Cl_w_comp.Where(c => c.MaterialID == bm.MaterialID).Sum(c => c.Pquantity), // 计划量
// ck_quantity = Funs.DB.Cl_w_comp.Where(c => c.MaterialID == bm.MaterialID).Sum(c => c.Pquantity) - Funs.DB.Cl_w_comp.Where(x => x.MaterialID == bm.MaterialID).Sum(c => c.OQuantity), // 最大允许出库量
// kc_quantity = Funs.DB.Cl_w_comp.Where(x => x.MaterialID == bm.MaterialID).Sum(c => c.SQuantity) - Funs.DB.Cl_w_comp.Where(x => x.MaterialID == bm.MaterialID).Sum(c => c.OQuantity) + Funs.DB.Cl_w_comp.Where(x => x.MaterialID == bm.MaterialID).Sum(c => c.RQuantity) - Funs.DB.Cl_w_comp.Where(x => x.MaterialID == bm.MaterialID).Sum(c => c.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
{
string strSql = "SELECT cp.ProjectId,cp.InstallationId,zz.Installationname AS InstallationName,ghfs AS Ghfs,cp.MaterialID,MaterialName,specificationtype AS Specificationtype,MaterialQuality,standardspecification ,unit AS Unit," +
"technicalconditions AS TechnicalConditions,SystemCode,";
if (!string.IsNullOrWhiteSpace(area))
{
strSql += "rtrim( ltrim( TAreaMaterialMID ) ) AS AreaCode,";
}
strSql += "0.000 AS bcckl,SUM ( Aquantity ) AS Aquantity,SUM ( Pquantity ) AS jh_quantity,SUM ( SQuantity ) AS dj_quantity,SUM ( HQuantity ) AS hj_quantity,SUM ( Pquantity ) - SUM ( OQuantity ) AS ck_quantity,SUM ( RQuantity ) AS tk_quantity,(SELECT SUM( SQuantity ) - SUM ( OQuantity ) + SUM ( RQuantity ) - SUM ( HQuantity ) FROM cl_w_comp WHERE cl_w_comp.MaterialID= cp.MaterialID AND cl_w_comp.InstallationId= cp.InstallationId AND cl_w_comp.ghfs= cp.ghfs ) AS kc_quantity,ROW_NUMBER ( ) OVER ( ORDER BY zz.InstallationCode,SystemCode ASC ) AS RowNum,0 AS xz,0 AS xh FROM cl_w_comp cp LEFT JOIN CL_B_Material mt ON mt.MaterialID= cp.MaterialID LEFT JOIN cl_b_Installation zz ON zz.InstallationId= cp.InstallationId GROUP BY cp.ProjectId,cp.InstallationId,zz.InstallationCode,zz.Installationname,ghfs,cp.MaterialID,MaterialName,specificationtype,MaterialQuality,standardspecification,unit,technicalconditions,SystemCode";
if (!string.IsNullOrWhiteSpace(area))
{
strSql += ", TAreaMaterialMID";
}
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += " HAVING cp.ProjectId= @ProjectId AND cp.installationid= @InstallationId AND ghfs = @ghfs";
listStr.Add(new SqlParameter("@ProjectId", ProjectId));
listStr.Add(new SqlParameter("@InstallationId", InstallationId));
listStr.Add(new SqlParameter("@ghfs", ghfs));
if (!string.IsNullOrWhiteSpace(area))
{
strSql += " AND TAreaMaterialMID = @area ";
listStr.Add(new SqlParameter("@area", area));
}
SqlParameter[] parameter = listStr.ToArray();
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
responeData.data = tb;
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
[HttpPost]
public Model.ResponeData UploadMaterialsFile(Model.Cl_file file)
{
Model.ResponeData responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
int count = db.Cl_file.Count();
Model.Cl_file new_file = new Model.Cl_file();
new_file.FID = Guid.NewGuid().ToString();
new_file.Ffl = file.Ffl;
new_file.Fname = file.Fname;
new_file.Fshm = file.Fshm;
new_file.UserTime = DateTime.Now;
new_file.UserID = file.UserID;
new_file.Flj = file.Flj;
new_file.Flx = file.Flx;
new_file.Bz = file.Bz;
new_file.InstallationId = file.InstallationId;
new_file.Unid = file.Unid;
new_file.ProjectId = file.ProjectId;
db.Cl_file.InsertOnSubmit(new_file);
db.SubmitChanges();
responeData.message = new_file.FID;
}
}
catch(System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}
@@ -0,0 +1,92 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Web.Http;
using WebAPI.Helpers;
namespace WebAPI.Controllers
{
public class MaterialsExitController : ApiController
{
#region
[HttpPost]
public Model.ResponeData AddMaterialExitM(Model.Cl_W_MaterialStorageM exit)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var userTime = DateTime.Now;
int count = db.Cl_W_MaterialStorageM.Where(x => x.UserTime.Value.Year == userTime.Year && x.UserTime.Value.Month == userTime.Month && x.UserTime.Value.Day == userTime.Day).ToList().Count();
Model.Cl_W_MaterialStorageM exitM = new Model.Cl_W_MaterialStorageM
{
StorageSheetMID = exit.StorageSheetMID,
StorageSheetCode = string.Format("RKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"), count.ToString("000")),
UserId = exit.UserId,
UserTime = DateTime.Now,
IsOk = "0", // 0-未审核,1-已审核
APid = exit.APid, // 采购方类别(甲乙供)
Specialityid = exit.Specialityid, // 专业ID
InstallationId = exit.InstallationId
};
exit.UserTime = DateTime.Now;
exit.StorageSheetCode = string.Format("CKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"), count.ToString("000"));
db.Cl_W_MaterialStorageM.InsertOnSubmit(exitM);
db.SubmitChanges();
responeData.data = exit;
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
[HttpPost]
public Model.ResponeData AddMaterialExitS(Model.Cl_W_MaterialStorageS s)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Cl_W_MaterialStorageS cws = new Model.Cl_W_MaterialStorageS();
cws.SystemCode = s.SystemCode;
cws.StorageQuantity = s.StorageQuantity; // 到货数量
cws.TheoryWeight = s.TheoryWeight; // 单价
cws.ActualWeight = s.ActualWeight; // 金额
cws.RecordTableOptions = s.RecordTableOptions; // 备注说明
cws.Manufacturer = s.Manufacturer; // 制造厂家
cws.ProjectId = s.ProjectId;
cws.StorageSheetMID = s.StorageSheetMID;
cws.StorageSheetSID = Guid.NewGuid().ToString();
cws.MaterialID = s.MaterialID;
db.Cl_W_MaterialStorageS.InsertOnSubmit(cws);
db.SubmitChanges();
responeData.data = "添加成功";
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}
@@ -0,0 +1,142 @@
using BLL;
using Model;
using System;
using System.Linq;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
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))
{
var userTime = DateTime.Now;
int count = db.Cl_W_MaterialOutM.Where(x => x.UserTime.Value.Year == userTime.Year&&x.UserTime.Value.Month==userTime.Month&&x.UserTime.Value.Day==userTime.Day).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;
MaterialOutM.OutSheetCode = string.Format("CKD--{0}{1}", DateTime.Now.ToString("yyyyMMdd"), count.ToString("000"));
db.Cl_W_MaterialOutM.InsertOnSubmit(outm);
db.SubmitChanges();
responeData.data = MaterialOutM;
}
}
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);
Model.Cl_W_MaterialOutM clw = db.Cl_W_MaterialOutM.FirstOrDefault(x => x.OutSheetMID == MaterialOutS.OutSheetMID);
if(clw.IsOk != "1")
{
clw.IsOk = "1";
}
db.SubmitChanges();
Model.Cl_w_comp cl = new Model.Cl_w_comp();
cl.CompID = Guid.NewGuid().ToString();
cl.ProjectId = MaterialOutS.ProjectId;
cl.InstallationId = clw.InstallationId;
cl.Ghfs = clw.YYPID;
cl.TAreaMaterialMID = MaterialOutS.FirstpartyCode;
cl.TAreaMaterialSID = "";
cl.MaterialID = MaterialOutS.MaterialID;
cl.Aquantity = 0;
cl.PlanSheetMID = "";
cl.PlanSheetSID = "";
cl.Pquantity = 0;
cl.StorageSheetMID = "";
cl.StorageSheetSID = "";
cl.SQuantity = 0;
cl.StorageHJSID = "";
cl.StorageHJMID = "";
cl.HQuantity = 0;
cl.OutSheetMID = MaterialOutS.OutSheetMID;
cl.OutSheetSID = outs.OutSheetSID;
cl.OQuantity = MaterialOutS.OutQuantity;
cl.ReturnSheetMid = "";
cl.ReturnSheetSID = "";
cl.RQuantity = 0;
db.Cl_w_comp.InsertOnSubmit(cl);
db.SubmitChanges();
responeData.data = MaterialOutS.OutSheetSID;
}
}
catch (System.Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}
+6 -1
View File
@@ -86,6 +86,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -175,7 +176,9 @@
<Compile Include="Controllers\HSSE\SafetyInspectionController.cs" />
<Compile Include="Controllers\HSSE\SafetyResponsibilitiesController.cs" />
<Compile Include="Controllers\HSSE\TrainTestRecordController.cs" />
<Compile Include="Controllers\MaterialEntranceAndExitController.cs" />
<Compile Include="Controllers\MaterialsExitController.cs" />
<Compile Include="Controllers\MaterialsBasicsController.cs" />
<Compile Include="Controllers\MaterialsOutController.cs" />
<Compile Include="Controllers\Person\PersonCheckController.cs" />
<Compile Include="Controllers\CQMS\CheckEquipmentController.cs" />
<Compile Include="Controllers\CQMS\CheckListController.cs" />
@@ -283,6 +286,8 @@
<Folder Include="Models\" />
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="Views\Login\" />
<Folder Include="Views\MaterialsBasics\" />
<Folder Include="Views\MaterialsOut\" />
<Folder Include="Views\Vehicle\" />
</ItemGroup>
<ItemGroup>