新增管道颜色标识导入功能及API控制器

更新了多个服务和页面,增加了导入管道颜色标识数据的功能,并实现了包装管理、车次管理、管道组件和焊口信息的API控制器。修正了文件路径错误,优化了分页和排序逻辑,删除了不再使用的API方法。
This commit is contained in:
2025-10-24 10:04:03 +08:00
parent 55b798135c
commit c23d113eae
55 changed files with 1502 additions and 817 deletions
@@ -1,5 +1,8 @@
using EmitMapper;
using FineUIPro;
using MiniExcelLibs;
using Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -190,5 +193,96 @@ namespace BLL
}
public static ResponeData ImportData( string path, string projectid)
{
var responeData = new ResponeData();
try
{
List<BaseMaterialcolorDataIn> temeplateDtoIns = MiniExcel.Query<BaseMaterialcolorDataIn>(path, startCell: "A1").ToList();
if (temeplateDtoIns == null || temeplateDtoIns.Count ==0)
{
responeData.code =0;
responeData.message = "导入数据为空!";
return responeData;
}
// 提取材质编码并验证非空
var materialCodes = new List<string>();
foreach (var row in temeplateDtoIns)
{
var code = (row.MaterialCode ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(code))
{
responeData.code =0;
responeData.message = "导入数据中材质列不能为空!";
return responeData;
}
materialCodes.Add(code);
}
var materialCodeList = materialCodes.Distinct().ToList();
// 从数据库验证这些材质编码是否存在
var existMaterials = (from m in Funs.DB.Base_Material
where materialCodeList.Contains(m.MaterialCode)
select new { m.MaterialCode, m.MaterialId }).ToList();
var existCodes = existMaterials.Select(x => x.MaterialCode).ToList();
var notExist = materialCodeList.Except(existCodes).ToList();
if (notExist.Count >0)
{
responeData.code =0;
responeData.message = string.Join(",", notExist) + " 材质不存在!";
return responeData;
}
// 插入数据
foreach (var row in temeplateDtoIns)
{
var code = (row.MaterialCode ?? string.Empty).Trim();
var mat = existMaterials.FirstOrDefault(x => x.MaterialCode == code);
if (mat == null)
{
responeData.code =0;
responeData.message = code + " 材质不存在!";
return responeData;
}
var colorName = string.IsNullOrWhiteSpace(row.ColorName) ? "—" : row.ColorName.Trim();
var colorCardNo = string.IsNullOrWhiteSpace(row.ColorCardNo) ? "—" : row.ColorCardNo.Trim();
var rgb = string.IsNullOrWhiteSpace(row.RGB) ? null : row.RGB.Trim();
var remark = string.IsNullOrWhiteSpace(row.Remark) ? null : row.Remark.Trim();
Model.Base_MaterialColor table = new Model.Base_MaterialColor
{
MaterialColorId = BLL.SQLHelper.GetNewID(typeof(Model.Base_MaterialColor)),
UnitId = string.Empty,
ProjectId = projectid,
MaterialId = mat.MaterialId,
ColorName = colorName,
ColorCardNo = colorCardNo,
RGB = rgb,
Remark = remark
};
Funs.DB.Base_MaterialColor.InsertOnSubmit(table);
}
Funs.DB.SubmitChanges();
responeData.code =1;
responeData.message = "导入成功!";
responeData.data = temeplateDtoIns.Count;
return responeData;
}
catch (Exception ex)
{
responeData.code =0;
responeData.message = "导入失败:" + ex.ToString();
return responeData;
}
}
}
}
@@ -35,7 +35,12 @@ namespace BLL
{ "预制散件" ,(int)TypeInt.},
{ "其他材料" ,(int)TypeInt.},
};
public static Dictionary<string, int> CategoryIntMap = new Dictionary<string, int>
{
{ "打捆" ,(int)CategoryInt.},
{ "装箱" ,(int)CategoryInt.},
{ "散装" ,(int)CategoryInt.},
};
#endregion Fields
#region Enums
@@ -46,6 +51,12 @@ namespace BLL
= 20,
= 30,
}
public enum CategoryInt : int
{
= 10,
= 20,
= 30,
}
#endregion Enums
@@ -73,6 +84,7 @@ namespace BLL
TrainNumber = newtable.TrainNumber,
TrainNumberId = newtable.TrainNumberId,
TypeInt = newtable.TypeInt,
CategoryInt = newtable.CategoryInt,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate
};
@@ -227,7 +239,9 @@ namespace BLL
StackingPosition = x.StackingPosition,
State = x.State,
TypeInt = x.TypeInt,
CategoryInt = x.CategoryInt,
TypeString = GetTypeString(x.TypeInt),
CategoryString = GetCategoryString(x.CategoryInt),
ReceiveMan = train.ContactName,//t.PersonName,
ReceiveDate = x.ReceiveDate.HasValue ? string.Format("{0:g}", x.ReceiveDate) : "",
PlanStartDate = GetMinPlanStartDate(x.PackagingManageId),
@@ -261,7 +275,10 @@ namespace BLL
{
return TypeIntMap.FirstOrDefault(c => c.Value == TypeInt).Key;
}
public static string GetCategoryString(int? CategoryInt)
{
return CategoryIntMap.FirstOrDefault(c => c.Value == CategoryInt).Key;
}
/// <summary>
/// 管线下拉框
/// </summary>
@@ -313,6 +330,7 @@ namespace BLL
table.TrainNumber = newtable.TrainNumber;
table.TrainNumberId = newtable.TrainNumberId;
table.TypeInt = newtable.TypeInt;
table.CategoryInt = newtable.CategoryInt;
db1.SubmitChanges();
}
}
@@ -344,6 +362,9 @@ namespace BLL
public string TrainNumberOld { get; set; }
public int? TypeInt { get; set; }
public string TypeString { get; set; }
public int? CategoryInt { get; set; }
public string CategoryString { get; set; }
#endregion Properties
}
@@ -1,19 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class TrainNumberManageService
{
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
{
private static IQueryable<Model.HJGL_TrainNumberManage> GetByQueryModle(Model.HJGL_TrainNumberManage table)
{
var q = from x in Funs.DB.HJGL_TrainNumberManage select x;
@@ -71,11 +63,11 @@ namespace BLL
return GetByQueryModle(table).ToList();
}
public static (List<Model.HJGL_TrainNumberManage> Data, int Total) GetListByQueryModle(Model.HJGL_TrainNumberManage table, int pageIndex = 0, int pageSize = 20)
public static (List<Model.HJGL_TrainNumberManage> Data, int Total) GetListByQueryModle(Model.HJGL_TrainNumberManage table, int pageIndex = 1, int pageSize = 20)
{
var baseQuery = GetByQueryModle(table);
var pagedData = baseQuery
.Skip((pageIndex) * pageSize)
.Skip((pageIndex-1) * pageSize)
.Take(pageSize)
.ToList();
@@ -94,10 +86,10 @@ namespace BLL
public static string GetNewTrainNumber(string ProjectId)
{
var q = from x in Funs.DB.HJGL_TrainNumberManage
where x.ProjectId == ProjectId
where x.ProjectId == ProjectId
select x.TrainNumber;
var max = q.Count();
var NewTrainNumber = (max + 1).ToString().PadLeft(2, '0');
var NewTrainNumber = string.Format("{0:yyyyMMdd}", DateTime.Now)+"-"+(max + 1).ToString().PadLeft(3, '0');
return NewTrainNumber;
}
@@ -353,13 +353,15 @@ namespace BLL
dt.Columns.Add("PipelineCode");
dt.Columns.Add("ManterialCode");
dt.Columns.Add("Specification");
dt.Columns.Add("MaterialColor");
for (int i = 0; i < tb.Rows.Count; i++)
{
var newRows = dt.NewRow();
newRows["PipelineCode"] = tb.Rows[i]["PipelineCode"].ToString();
newRows["ManterialCode"] = getMaterialCodeByPipelineId(tb.Rows[i]["PipelineId"].ToString());
newRows["ManterialCode"] = getMaterialCodeByPipelineId(tb.Rows[i]["PipelineId"].ToString(),out string MaterialColor);
newRows["Specification"] = getSpecificationByPipelineId(tb.Rows[i]["PipelineId"].ToString());
newRows["MaterialColor"] = MaterialColor;
dt.Rows.Add(newRows);
}
@@ -878,18 +880,47 @@ namespace BLL
#region
public static string getMaterialCodeByPipelineId(string pipelineId)
public static string getMaterialCodeByPipelineId(string pipelineId, out string materialColor)
{
string materialCode = string.Empty;
materialColor = string.Empty;
if (!string.IsNullOrEmpty(pipelineId))
{
var weldjoint = (from x in Funs.DB.HJGL_WeldJoint
join y in Funs.DB.Base_Material on x.Material1Id equals y.MaterialId
join z in Funs.DB.Base_Material on x.Material2Id equals z.MaterialId
where x.PipelineId == pipelineId
select new { MaterialCode1 = y.MaterialCode, MaterialCode2 = z.MaterialCode }).FirstOrDefault();
select new
{
MaterialId1 = y.MaterialId,
MaterialCode1 = y.MaterialCode,
MaterialId2 = z.MaterialId,
MaterialCode2 = z.MaterialCode,
x.ProjectId,
}).FirstOrDefault();
if (weldjoint != null)
{
if (!string.IsNullOrEmpty(weldjoint.MaterialId1))
{
var projectSet = Project_SysSetService.GetSysSetBySetId("11", weldjoint.ProjectId);
Model.BaseMaterialcolorOutput queryModel = new Model.BaseMaterialcolorOutput();
queryModel.ProjectId = weldjoint.ProjectId;
queryModel.MaterialId = weldjoint.MaterialId1;
var material1 = BLL.BaseMaterialcolorService.GetListByQueryModle(queryModel).FirstOrDefault();
if (material1 != null)
{
if (projectSet != null && projectSet.SetValue == "1")
{
materialColor = material1.ColorName;
}
else
{
materialColor= material1.ColorCardNo;
}
}
}
if (!string.IsNullOrEmpty(weldjoint.MaterialCode1) && !string.IsNullOrEmpty(weldjoint.MaterialCode2))
{
materialCode = weldjoint.MaterialCode1 + "/" + weldjoint.MaterialCode2;
@@ -908,8 +939,7 @@ namespace BLL
}
}
return materialCode;
}
}
public static string getSpecificationByPipelineId(string pipelineId)
{
string spcificaation = string.Empty;
@@ -497,6 +497,7 @@ namespace BLL
Model.SGGLDB db = Funs.DB;
var q = (from x in db.HJGL_Pipeline_Component
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
orderby y.PipelineCode,x.PipelineComponentCode
where y.ProjectId.Contains(projectId) && x.State.Equals(State1) &&
(string.IsNullOrEmpty(pipelineCode) || y.PipelineCode.Contains(pipelineCode)) &&
(string.IsNullOrEmpty(pipelineComponentCode) || x.PipelineComponentCode.Contains(pipelineComponentCode)) &&